Adding filter queries (FS) to a soler query using

2019-08-28 14:25发布

问题:

I am trying to query solr using solrj and I can't seem to find the way to and a fq argument to my code

here is the http request I am trying to run

select?wt=json&indent=true&fl=name,store&q=*:*&fq=!geofilt%20pt=45.15,-93.85%20sfield=store%20d=5}

and here is my code

SolrServer server = new HttpSolrServer("the host");
SolrQuery query = new SolrQuery();
query.setQuery( "*" );
query.setParam("fl","name,price");

How do I add the setParam for the fq "!geofilt pt=45.15,-93.85 sfield=store d=5" I assume it is something line query.setParam("fq","the fq field") but nothing seems to work for me.

Thanks,

Shimon

回答1:

Can you use addFilterQuery?

SolrQuery query = new SolrQuery();
query.setQuery( "*" );
query.setParam("fl","name,price");
query.addFilterQuery("{!geofilt pt=45.15,-93.85 sfield=store d=5}");


回答2:

You can also query like

query.set(CommonParams.FQ, "{!geofilt pt=45.15,-93.85 sfield=store d=5}");


标签: solr solrj