【问题标题】:elasticsearch percolator filter failselasticsearch percolator 过滤器失败
【发布时间】:2016-10-06 10:33:32
【问题描述】:

我正在对运行正常的过滤器使用文档查询。当我尝试使用查询 ID 过滤过滤器查询时,它不会返回任何结果。例如:

{
  "doc" : {
   "text" : "This is the text within my document"
  },
  "highlight" : {
   "order" : "score",
   "pre_tags" : ["<example>"],
   "post_tags" : ["</example>"],
   "fields" : {
   "text" : { "number_of_fragments" : 0 }
  }
 },
 "filter":{"ids":{"values":[11,15]}}
,
 "size" : 100
}

我确定这些 id 是正确的,但总是获得"matches" : [ ]。当我不使用过滤器时,ES 会检索正确的匹配项。 感谢您的帮助。

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    我想我已经解决了。似乎the filter only works on the "metadata" fields,这意味着您必须向过滤器中索引的查询添加自定义字段,以便在需要时使用它们进行过滤。 使用我之前的示例,我必须在过滤器查询中建立索引,例如:

    {
        "query" : {
          "match_phrase" : {
            "text" : "document"
          }
        },
        "id" : 11
      }
    

    “手动”添加一个冗余的 id 字段,以便稍后将其用作过滤器参考。 在渗透时,你必须使用类似的东西:

    {
      "doc" : {
       "text" : "This is the text within my document"
      },
     "filter":{"match":{"id":11}},
      "highlight" : {
       "order" : "score",
       "pre_tags" : ["<example>"],
       "post_tags" : ["</example>"],
       "fields" : {
       "text" : { "number_of_fragments" : 0 }
      }
     },
     "size" : 100
    }
    

    为了只使用过滤器查询。补充信息可以在here找到。

    【讨论】:

      猜你喜欢
      • 2015-01-10
      • 2015-09-26
      • 2021-04-10
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多