Solr - {!ex} 在一个方面查询

标签 solr lucene

背景

我正在尝试将 2 个单独工作的功能结合起来,但在使它们协同工作时遇到了麻烦。

*1) 如 solr wiki 所述我可以标记一个特定的 fq,然后在我的 facet.field 中排除它。即使在选择一个值时,这也会使我的 facet 计数保持不变,如下所示:

fq={!tag=pt}price:100&facet=true&facet.field={!ex=pt}price

*2)我想使用 facet.query 如下:
facet=true&facet.query=price:[0 TO 100]&facet.query=price:[100 TO *]

所以我想结合*1 & *2,这是我尝试过的:
fq={!tag=pt}price:[0 to 100]&facet=true&facet.query={!ex=pt}price:[0 TO 100]&facet.query={!ex=pt}price:[100 TO *]

实际发生的是我从 Solr 收到回复:
<lst name="facet_queries">
    <int name="{!ex=pt}price:[0 TO 100]">8</int>
    <int name="{!ex=pt}price:[100 TO *]">19</int>
</lst>

我的问题是:

为什么 {!ex=pt} 是名称的一部分?它搞乱了我的一些逻辑。
也许我误用了它,如果是这样,那么正确的方法是什么?

更多信息

我期待的是:(如果在没有 *1 的情况下运行 *2,则与我收到的相同)
<lst name="facet_queries">
    <int name="price:[0 TO 100]">8</int>
    <int name="price:[100 TO *]">19</int>
</lst>

这是有道理的,因为如果我正在运行 *1,这就是我在 facet_fields 中收到的:
<lst name="facet_fields">
    <lst name="price">
        <int name="80">8</int>
        <int name="150">19</int>
    </lst>
</lst>

它没有说 name="{!ex=pt}price"

最佳答案

我认为这是因为:

  • *1示例使用 facet.field它应该以其使用的字段命名(没有任何排除信息)。
  • *2示例使用 facet.query这应该代表 query (在查询中使用所有可能的信息......显示查询的一部分是没有意义的,例如没有排除部分)


  • 无论如何,如果需要命名使用排除功能的特定方面,则可以通过以下方式完成(使用 参数):
    facet.field={!ex=pt key=good_name_for_a_facet}price
    对于 facet.query 也有同样的作用……例如,如果您确实想隐藏 ex 部分:
    facet.query={!ex=pt key=$queryOne}price:[0 TO 100]
    其中 queryOne 是作为 queryOne=price:[0 TO 100] 传递给 solr 的原始参数的一部分

    所以最终的查询看起来像这样:
    fq={!tag=pt}price:[0 TO 100]&facet=true&facet.query={!ex=pt key=$queryOne}price:[0 TO 100]&facet.query={!ex=pt key=$queryTwo}price:[100 TO *]&queryOne=price:[0 TO 100]&queryTwo=price:[100 TO *]
    

    附言我已经将外部参数用于 key ,因为这样 - 不需要对特殊字符进行手动转义。

    关于Solr - {!ex} 在一个方面查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20983856/

    相关文章:

    solr - 如何使用 Jetty 9 对动态内容启用 Gzip 压缩

    apache - Nutch无法删除重复项(在一个Solr核心上,但在另一个核心上)

    Solr 过滤器查询 - 字符串与整数

    ruby-on-rails - 使用 sunspot solr 获取相关搜索查询

    search - Solr 关键字中的小写和大写

    lucene - Sitecore Lucene : content delivery server index not updating on publish

    java - Spring Solr 存储库

    solr - Solr 添加和 Solr 提交之间的区别

    lucene - 使用 Lucene 荧光笔返回完整字段文本

    elasticsearch - 我们可以在 ElasticSearch 中的嵌套聚合上应用桶选择器聚合吗?