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

喜你入骨 提交于 2019-12-13 07:11:47

问题


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


来源:https://stackoverflow.com/questions/18596789/adding-filter-queries-fs-to-a-soler-query-using-solrj

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!