On 2/19/2018 6:44 AM, Aakanksha Gupta wrote:
http://localhost:8983/solr/geoloc/select/?q=*:*&fq={!geofilt}&sfield=latlong&pt=-6.08165,145.8612430&d=100&wt=json&fq=timestamp:[1518908400000%20TO%201518912000000]&fl=*,_dist_:geodist()
But I'm not sure how to build the SolrJ equivalent of this query using
SolrQuery.
I haven't done anything with spatial yet. But I do know how to
translate Solr URLs into SolrJ code. The code below constructs a query
object equivalent to that URL. If that URL works as-is, this code
should do the same.
I did not include the "wt" parameter, which controls the format of the
response. With SolrJ, the transfer format defaults to binary and should
not be changed. It CAN be changed, but any other choice would be less
efficient, and the programmer doesn't need to worry about it.
query.setQuery("*:*");
query.addFilterQuery("{!geofilt}");
query.addFilterQuery("timestamp:[1518908400000%20TO%201518912000000]");
query.set("sfield", "latlong");
query.set("pt", "-6.08165,145.8612430");
query.set("d", "100");
query.setFields("*", "_dist_:geodist()");
I couldn't actually test this code, as I don't have any indexes with
spatial data.
Thanks,
Shawn