Search code examples
solrsolrj

Adding filter queries (FS) to a soler query using solrj


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


Solution

  • 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}");