Solr to remove faceted field when it doesn't have any data

我与影子孤独终老i 提交于 2020-01-14 03:58:29

问题


Working with Solr for ASP.net project using Solrnet library.

While querying with Faceted field set to true for several fields, it returns blank faceted fields in the results as well. Is there any way using which we can instruct Solr to remove those faceted fields which does not have any result into it.

So the final results doesn't include any facet field with no data. I'm not referring to min.count parameter, this works fine. But I'm referring to the facet field which stays there even if there is no data inside it.

Please comment if you didn't get my point. Thank you in advance for helping me.


回答1:


Set facet.mincount to 1.
This will ensure facets with at least one record will be returned. By default the value is 0.

Edit :- Sorry didn't get the facet part here. The Facets are always returned if even no matches in it. So the handling needs to be on the client side.




回答2:


If you want to remove facets having count = 0 then you need to Optimize your Core. That is one of the way i found. I tested it on SOLR version 6.3.X

To optimize the Core, go to SOLR Admin page and select core you want to Optimize. or Use CURL.

The CURL will look like this -

curl http://<host_name>:8983/solr/<core_name>/update -F stream.body=' <optimize />'

Hope this helps!



来源:https://stackoverflow.com/questions/11897189/solr-to-remove-faceted-field-when-it-doesnt-have-any-data

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