Thanks Erick. On Tue, Feb 20, 2018 at 1:11 AM, Erick Erickson <erickerick...@gmail.com> wrote:
> Aakanksha: > > Be a little careful here, filter queries with timestamps can be > tricky. The example you have is fine, but for end-points with finer > granularity may be best if you don't cache them, see: > https://lucidworks.com/2012/02/23/date-math-now-and-filter-queries/ > > Best, > Erick > > On Mon, Feb 19, 2018 at 7:49 AM, Aakanksha Gupta > <aakankshagupta2...@gmail.com> wrote: > > Hi Shawn, > > Thanks for the quick solution. It works. I just had to replace %20 to > space > > in query.addFilterQuery("timestamp:[1518908400000 TO 1518912000000]"); > > > > Thanks a ton! :) > > > > On Mon, Feb 19, 2018 at 11:43 PM, Shawn Heisey <elyog...@elyograg.org> > > wrote: > > > >> 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() > >>> <http://localhost:8983/solr/geoloc/select/?q=*:*&fq=%7B! > geofilt%7D&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 > >> > >> >