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 Harshvardhan Ojha <Ha...@makemytrip.com> on 2013/03/20 12:21:46 UTC

Spatial Search with document score as distance between two points

Hi All,

I am using spatial search from mobile to find offers nearby that lat long.
Query:
q={!func}geodist()&sfield=latlng&pt=28.635308,77.22496&sort=score+asc

using this query I am getting distance in kms in score of solr documents.

Problem : For those documents which doesn't have latlng field, value is coming exceptionally large '8763.191'.
How can I limit this maximum distance(i.e score) as 25?

regards
Harshvardhan Ojha | Software Developer - Technology Development

  | MakeMyTrip.com, 243 SP Infocity, Udyog Vihar Phase 1, Gurgaon, Haryana - 122 016, India

[Description: http://www.mailmktg.makemytrip.com/signature/images/bulb.gif]What's new?: RoutePlanner- Discover One Billion ways to travel<http://routeplanner.makemytrip.com/>.


[Description: http://www.mailmktg.makemytrip.com/signature/images/MMT-signature-footer-V4.gif]<http://www.makemytrip.com/>

[Description: http://www.mailmktg.makemytrip.com/signature/images/map-icon.gif]<http://www.makemytrip.com/support/gurgaon-travel-agent-office.php>
Office Map

[Description: http://www.mailmktg.makemytrip.com/signature/images/facebook-icon.gif]<http://www.facebook.com/pages/MakeMyTrip-Deals/120740541030?ref=search&sid=100000077980239.1422657277..1>
Facebook

[Description: http://www.mailmktg.makemytrip.com/signature/images/twitter-icon.gif]<http://twitter.com/makemytripdeals>
Twitter





The contents of this email, including the attachments, are PRIVILEGED AND CONFIDENTIAL to the intended recipient at the email address to which it has been addressed. If you receive it in error, please notify the sender immediately by return email and then permanently delete it from your system. The unauthorized use, distribution, copying or alteration of this email, including the attachments, is strictly forbidden. Please note that neither MakeMyTrip nor the sender accepts any responsibility for viruses and it is your responsibility to scan the email and attachments (if any). No contracts may be concluded on behalf of MakeMyTrip by means of email communications.

Re: Spatial Search with document score as distance between two points

Posted by Chris Hostetter <ho...@fucit.org>.
: q={!func}geodist()&sfield=latlng&pt=28.635308,77.22496&sort=score+asc
	...
: Problem : For those documents which doesn't have latlng field, value is coming exceptionally large '8763.191'.

I'm pretty sure you're seeing the function assume a default lat,lon of 
"0,0" for docs thta you haven't given a position.

If you don't have a location on every doc, you're probably going to want 
to use a filter query to exclude docs that have no location -- i'm not 
sure off the top of my head how to do that.

: How can I limit this maximum distance(i.e score) as 25?

apply another fq that filters by distance, either using bbox or geofilt...

http://wiki.apache.org/solr/SpatialSearch#bbox_-_Bounding-box_filter
http://wiki.apache.org/solr/SpatialSearch#geofilt_-_The_distance_filter

...but you'll still want to find a way ot filter out docs with no latlon 
values, otherwise you're going to get false positives if your input point 
ever happens to be within 25km of "0,0"


-Hoss