how to search for more than one facet in solr?

匆匆过客 提交于 2019-12-22 11:16:45

问题


I need to search for facets in solr as below:

  • fq=country:usa
  • fq=country:canada
  • fq=topic:industrial
  • fq=topic:political
  • now i need to search for the articles that have the above facets (logical And) and (logical Or).
    suppose that i have the following articles

    1. country=USA France //Topic: Industrial Scientific
    2. country=USA canada //Topic: Industrial
    3. country=USA canada //Topic: Industrial political

    now, i have tried

    http://127.0.0.1:8888/solr/Collection1/select?q=*:*&start=0&rows=10&facet=true&fq=country:USA&fq=country:canada&fq=topic:political&fq=topic:industrial
    

    but this didnt return anything :( could you please guide me to how to search for those faces by ANDing and ORing between them
    Thanks for your help


    回答1:


    You can use boolean operators to filter the results.

    OR - fq=country:(USA OR canada)&fq=topic:(political OR industrial)

    AND - fq=country:(USA AND canada)&fq=topic:(political AND industrial)




    回答2:


    This sort of thing would be even easier if the Solr devs implement this feature request:

    https://issues.apache.org/jira/browse/SOLR-1223

    It like it because then each fq can be specified (and cached) separately and the AND/OR logic of the fq's is separated out. Your case is pretty straightforward and the above answer just fine, but when you get some nasty fq's simply AND'ing them all together is not powerful enough.



    来源:https://stackoverflow.com/questions/8065146/how-to-search-for-more-than-one-facet-in-solr

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