lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Ingersoll <>
Subject Re: Function queries question
Date Fri, 20 Nov 2009 13:53:22 GMT

On Nov 20, 2009, at 3:15 AM, Oliver Beattie wrote:

> Hi all,
> I'm a relative newcomer to Solr, and I'm trying to use it in a project
> of mine. I need to do a function query (I believe) to filter the
> results so they are within a certain distance of a point. For this, I
> understand I should use something like sqedist or hsin, and from the
> documentation on the FunctionQuery page, I believe that the function
> is executed on every "row" (or "record", not sure what the proper term
> for this is). So, my question is threefold really; are those functions
> the ones I should be using to perform a search where distance is one
> of the criteria (there are others),

Short answer: yes.  Long answer:  I just committed those functions this week.  I believe they
are good, but feedback is encouraged.

> and if so, does Solr execute the
> query on every row (and again, if so, is there any way of preventing
> this [like subqueries, though I know they're not supported])?

You can use the frange capability to filter first.  See

Here's an example from a soon to be published article I'm writing:
http://localhost:8983/solr/select/?q=*:*&amp;fq={!frange l=0 u=400}hsin(0.57, -1.3, lat_rad,
lon_rad,  3963.205)

This should filter out all documents that are beyond 400 miles in distance from that point
on a sphere (specified in radians, see also the rads() method)

> Sorry if this is a little confusing… any help would be greatly appreciated :)

No worries, a lot of this spatial stuff is still being ironed out.  See
for the issue that is tracking all of the related issues.  The pieces are starting to come
together and I'm pretty excited about it b/c not only will it bring native spatial support
to Solr, it will also give Solr some exciting new general capabilities (sort by function,
pseudo-fields, facet by function, etc.)
View raw message