Filter / function query to compare distance with field value
Can anyone help me to write a function query which compares the distance between a fixed point (supplied in the query) and a point stored per document with a distance stored in that document?
I am new to Solr and beyond knowing I can't use a filter query and that I will presumably need to use geodist() and fieldvalue('location') and fieldval开发者_运维技巧ue('point') I don't know where to start! Any help would be appreciated!
I am using Solr 3.2.
Turns out I can use a filter query with a range function to solve this (Solr 1.4+). For this case I used:
...&fq={!frange+l=0+u=9999999}sub(DocDistance,geodist(DocLocation,lat,lng))
Which will get the distance between the input point and the point on the document, then subtract the distance stored on the document before filtering out those where this value is less than 0 (9999999 approx= infinity).
PHEW! That was hard work! HTH someone in future.
精彩评论