Elasticsearch前缀匹配消失不添加(QueryString) [英] Elasticsearch prefix matching disappears with NOT added (QueryString)

查看:319
本文介绍了Elasticsearch前缀匹配消失不添加(QueryString)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Elasticsearch QueryStrings:部分匹配NOT查询?

我确定我不能部分匹配NOT查询,但我仍然希望部分匹配先例not-NOT查询。例如,我有一个这样的查询:蓝色向导NOT fire ,前缀匹配。我有一些结果,当我搜索蓝色向导时会显示文本蓝色向导,但消失当我添加 NOT fire part;就像NOT查询正在擦除部分匹配一样。

I determined that I couldn't partially match a NOT query, but I still wish to partially match a precedent not-NOT query. For example, I have a query like this: "blue wizard" NOT fire, with prefix matching. I have a few results that have the text blue wizards that show up when I search "blue wizard" but that disappear when I add the NOT fire part; it's as if the NOT query is erasing the partial matching.

这是发送到ES的结果查询:

This is the resulting query sent to ES:

{
  "query": {
    "bool": {
      "should": [
        {
          "queryString": {
            "fields": [
              "reminderlessText"
            ],
            "query": "\"blue wizard\" NOT fire",
            "defaultOperator": "OR"
          }
        },
        {
          "multi_match": {
            "query": "\"blue wizard\" NOT fire",
            "type": "phrase_prefix",
            "fields": [
              "reminderlessText"
            ]
          }
        }
      ]
    }
  }
}

推荐答案

通过在一个查询中组合query_string和multi_match,使您的测试查询更复杂的任何原因?

Any reason why you make your test query more complicated by combining the query_string and multi_match in one query?

单独查看:
Y我们的query_string子查询没有说明任何关于前缀的内容,所以它显然不符合蓝色向导(除了您使用词干或词汇化过滤器,请参见下文。)

Looking at it separately: Your query_string sub-query doesn't say anything about prefixes, so it obviously doesn't match "blue wizards" (except you use a stemming or lemmatization filter, see below.)

您的multi_match子查询ist类型为phrase_prefix,但在(多)匹配查询中,您不能使用像NOT这样的运算符。
此查询解析为:给我所有包含

Your multi_match sub-query ist of type "phrase_prefix", but in a (multi_)match query you cannot use operators like NOT. This query resolves to: give me all docs that contain


  • 蓝色wizzard的文档(不知道引号会发生什么,取决于在您的分析仪上)

  • 后跟单词NOT

  • ,然后是以火开始的东西

这显然不是你想要的。

我想你的实际问题是:搜索向导的人也应该找到复数向导出现的文档。
在这种情况下,你想潜入干扰的主题。
这可能是一个很好的起点:$ b​​ $ b https://www.elastic.co/guide/en/elasticsearch/guide/current/choosing-a-stemmer.html http://www.intrafind.de/blog/the-difference-between-stemming-and-lemmatization-en

I guess your actual problem is: "People searching for 'wizard' should also find docs where the plural 'wizards' appears". In that case, you want to dive into the topic of stemming. This might be a good starting point: https://www.elastic.co/guide/en/elasticsearch/guide/current/choosing-a-stemmer.html or http://www.intrafind.de/blog/the-difference-between-stemming-and-lemmatization-en

这篇关于Elasticsearch前缀匹配消失不添加(QueryString)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆