Best way to combine a SolrQueryByDistance with other query parameters?

192 views
Skip to first unread message

Matthew Shapiro

unread,
Oct 27, 2013, 5:40:39 PM10/27/13
to sol...@googlegroups.com
It appears that the SolrQueryByDistance class does not inherit from AbstractSolrQuery.  I need to use the distance query as part of a more complicated query (e.g. I want to find all documents with subtype:person and is 5 miles from location x/y).  Most query clauses I am currently combining using query = query && new SolrQuery(), but i am unable to do this with the SolrQueryByDistance class.

Technically it appears like I might be able to do query = query && new SolrQuery(new SolrQueryByDistance("test", new Location(0,0), 1).Query); but is this the proper way to do this?

Thanks,

Mauricio Scheffer

unread,
Oct 27, 2013, 9:30:25 PM10/27/13
to sol...@googlegroups.com
Yeah, this sucks. I've hit this issue myself, and I worked around it by wrapping the geo query, e.g.:

var geo = new SolrQueryByDistance(...)
var geoq = new SolrQuery(geo.Query) { Quoted = false }

IIRC there were issues with making it inherit AbstractSolrQuery because it's actually a localparam, but I can't remember what they were concretely :-(

It would be great if you could test a query on Solr like "{!geofilt ...} AND some_other_query", and "-{!geofilt ...}", if those work correctly I think it should be safe to make it inherit AbstractSolrQuery.

Cheers




--
Mauricio


--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.
To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages