Multiple ranges in a facet in solr

馋奶兔 提交于 2019-12-01 11:35:13

问题


How could you format a Solr facet query to include two page view ranges?

The following will only return the 200 TO 250 range and nothing from the 500 to 550 range.

<str name="fq">pageviews:[200 TO 250] OR [500 TO 550]</str>

I'm keen to get the number of records matching people with pages views between 200 and 250 and between 500 and 550.


回答1:


You can also use it as shown below.

fq=pageviews:([200 TO 250] OR [500 TO 550])



回答2:


Turns out I need to mention the field each time:

pageviews:[200 TO 250] OR pageviews:[500 TO 550]



回答3:


I believe that the complete answer to this question should include a way to configure all the parameters of these "repeated" facets. This is how it would be done in Solr 4.4.0, using JSON.

"facet.range": [

    "{!key=twohundred " +
        "f.pageviews.facet.range.start=200 " +
        "f.pageviews.facet.range.end=250 " + 
        "f.pageviews.facet.range.gap=1 " +
    "}pageviews",

    "{!key=fivehundred " +
        "f.pageviews.facet.range.start=500 " +
        "f.pageviews.facet.range.end=550 " + 
        "f.pageviews.facet.range.gap=10 " +
    "}pageviews"

]

(Notice that each entry in the array is supposed to be a string without linebreaks, but are divided here for clarity.)

This way each facet can be individually labeled, modified (I changed the gap for 'fivehundred'), or any other parameters can be added (like 'facet.range.other').

Source: https://issues.apache.org/jira/browse/SOLR-1351



来源:https://stackoverflow.com/questions/12580100/multiple-ranges-in-a-facet-in-solr

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