You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by PeterKerk <pe...@hotmail.com> on 2015/11/23 01:39:16 UTC
geolocation search ignores distance parameter
Why is the result below returned even though I'm filtering in a radius of 20
from geocoordinates defined in pt parameter in the querystring?
As you can see the result in _dist_ in this result is is far larger than 20.
http://localhost:8983/solr/locs/select/?indent=on&facet=true{!geofilt}&pt=51.98,5.91111&sfield=geolocation&d=20&sort=geodist()%20asc&q=*:*&start=0&rows=12&fl=id,_dist_:geodist(),lat,lng
<result name="response" numFound="20" start="0">
<doc>
<str name="lng">4.205799299999967</str>
<str name="id">1803</str>
<str name="lat">51.5320753</str>
<double name="_dist_">127.50432946951436</double>
</doc>
</result>
schema.xml definitions
<fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
<field name="lng" type="string" indexed="true" stored="true"/>
<field name="lat" type="string" indexed="true" stored="true"/>
<field name="geolocation" type="location" indexed="true" stored="true"/>
I tried adding this to the query string: &fq=_dist_:10
but then I get the error: undefined field _dist_
--
View this message in context: http://lucene.472066.n3.nabble.com/geolocation-search-ignores-distance-parameter-tp4241564.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: geolocation search ignores distance parameter
Posted by Shawn Heisey <ap...@elyograg.org>.
On 11/22/2015 5:39 PM, PeterKerk wrote:
> Why is the result below returned even though I'm filtering in a radius of 20
> from geocoordinates defined in pt parameter in the querystring?
> As you can see the result in _dist_ in this result is is far larger than 20.
>
> http://localhost:8983/solr/locs/select/?indent=on&facet=true{!geofilt}&pt=51.98,5.91111&sfield=geolocation&d=20&sort=geodist()%20asc&q=*:*&start=0&rows=12&fl=id,_dist_:geodist(),lat,lng
Disclaimer: I've never used any of the spatial features in Solr. I
have no idea whether I've got right or wrong info here.
I did some digging in the documentation, and based on what I found, your
geofilt syntax looks wrong. I'm reasonably sure that localparams like
{!geofilt} must be at the beginning of the main query or a filter query
-- they cannot stand alone, and attaching it to the facet parameter
seems incorrect. Adjusting your parameter list so it looks right, I get
the following:
indent=on
facet=true
fq={!geofilt sfield=geolocation}
pt=51.98,5.91111
d=20
sort=geodist() asc
q=*:*
start=0
rows=12
fl=id,_dist_:geodist(),lat,lng
Thanks,
Shawn
Re: geolocation search ignores distance parameter
Posted by PeterKerk <pe...@hotmail.com>.
@Erik: thanks, overlooked that...added fq= before geofilt and now it works :)
--
View this message in context: http://lucene.472066.n3.nabble.com/geolocation-search-ignores-distance-parameter-tp4241564p4241571.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: geolocation search ignores distance parameter
Posted by Erik Hatcher <er...@gmail.com>.
Looks like your query doesn't actually make geofilt be an actual fq parameter.
> On Nov 22, 2015, at 19:39, PeterKerk <pe...@hotmail.com> wrote:
>
> Why is the result below returned even though I'm filtering in a radius of 20
> from geocoordinates defined in pt parameter in the querystring?
> As you can see the result in _dist_ in this result is is far larger than 20.
>
> http://localhost:8983/solr/locs/select/?indent=on&facet=true{!geofilt}&pt=51.98,5.91111&sfield=geolocation&d=20&sort=geodist()%20asc&q=*:*&start=0&rows=12&fl=id,_dist_:geodist(),lat,lng
>
> <result name="response" numFound="20" start="0">
> <doc>
> <str name="lng">4.205799299999967</str>
> <str name="id">1803</str>
> <str name="lat">51.5320753</str>
> <double name="_dist_">127.50432946951436</double>
> </doc>
> </result>
>
> schema.xml definitions
>
> <fieldType name="location" class="solr.LatLonType"
> subFieldSuffix="_coordinate"/>
> <field name="lng" type="string" indexed="true" stored="true"/>
> <field name="lat" type="string" indexed="true" stored="true"/>
> <field name="geolocation" type="location" indexed="true" stored="true"/>
>
>
>
> I tried adding this to the query string: &fq=_dist_:10
>
> but then I get the error: undefined field _dist_
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/geolocation-search-ignores-distance-parameter-tp4241564.html
> Sent from the Solr - User mailing list archive at Nabble.com.