在elasticsearch中使用通配符搜索全文

问题描述 投票:0回答:1

我想在“文本”字段中搜索“具有AT1的任何字符串或具有pro的任何字符串”的短语。这是我查询的一部分:

"query_string" : {
                "query" : "text:*AT1* *pro*",
                "fields" : [ ],
                "use_dis_max" : true,
                "tie_breaker" : 0.0,
                "default_operator" : "or",
                "auto_generate_phrase_queries" : false,
                "max_determinized_states" : 10000,
                "enable_position_increments" : true,
                "fuzziness" : "AUTO",
                "fuzzy_prefix_length" : 0,
                "fuzzy_max_expansions" : 50,
                "phrase_slop" : 0,
                "escape" : false,
                "split_on_whitespace" : true,
                "boost" : 1.0,
                "allow_leading_wildcard": true, 
                "analyze_wildcard":true
              }

但是它不起作用。它显示所有文档。我的问题在哪里?

elasticsearch full-text-search wildcard
1个回答
0
投票

您的查询应类似于:

{
  "query": {
    "query_string": {
      "default_field": "text",
      "query": "at1 AND pro"
    }
  }
}

此外,由于存在许多解决问题的方法,因此您可以阅读有关full-text queriescompound queries的文档

© www.soinside.com 2019 - 2024. All rights reserved.