【问题标题】:search full-text with wildcard in elasticsearch在 elasticsearch 中使用通配符搜索全文
【发布时间】:2019-10-16 12:57:53
【问题描述】:

我想在提交的“文本”中搜索这个短语“任何具有 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】:

您的查询应该是这样的:

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

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

【讨论】:

  • 但是这个查询没有完全响应。我希望任何文本都有 at1 或 pro 例如“asdsfdAT1”或“sadfsfdAT1asdd”和d .....。我可以分别使用两个查询字符串,“ query" : "text:*AT1*" 和 "query" : "text:*pro*",但我想要两个,合并这些查询字符串。我测试了这个查询 "query" : "text:*AT1* pro" 但没有用
  • 然后使用 edge_ngram 分析器从 min_gram=3 开始。这将比通配符更有效...
猜你喜欢
  • 1970-01-01
  • 2015-03-15
  • 1970-01-01
  • 1970-01-01
  • 2018-12-06
  • 2023-03-12
  • 2011-03-23
  • 1970-01-01
  • 2023-03-20
相关资源
最近更新 更多