Faceting using SolrJ and Solr4

坚强是说给别人听的谎言 提交于 2019-12-05 08:26:18

Actually you need only to set facet field and facet will be activated (check SolrJ source code):

solrQuery.addFacetField("country");

Where did you look for facet information? It must be in QueryResponse.getFacetFields (getValues.getCount)

In the solr Response you should use QueryResponse.getFacetFields() to get List of FacetFields among which figure "country". so "country" is idenditfied by QueryResponse.getFacetFields().get(0)

you iterate then over it to get List of Count objects using

QueryResponse.getFacetFields().get(0).getValues().get(i)

and get value name of facet using QueryResponse.getFacetFields().get(0).getValues().get(i).getName() and the corresponding weight using

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