elasticsearch - 在Elasticsearch中搜索而无需标记化关键字

标签 elasticsearch elasticsearch-5

{
   "from": 0,
   "size": 100,
   "query": {
       "bool": {
           "must": [
               {
                   "simple_query_string": {
                       "query": "template testing",
                       "fields": [
                           "tag^8.0",
                           "title^10.0",
                           "body^3.0"
                       ],
                       "flags": -1,
                       "default_operator": "or",
                       "analyze_wildcard": false,
                       "auto_generate_synonyms_phrase_query": false,
                       "fuzzy_prefix_length": 0,
                       "fuzzy_max_expansions": 50,
                       "fuzzy_transpositions": true,
                       "boost": 1
                   }
               },

           ],
           "filter": [
               {
                   "terms": {
                       "assetCourse.assetType": [
                           "epub"
                       ],
                       "boost": 1
                   }
               }
           ],

           "adjust_pure_negative": true,
           "boost": 1
       }
   },

 "sort": { "_score": { "order": "desc" }}

}

我想先搜索确切的关键字“模板测试”,然后使用"template"和“测试”进行标记化搜索,但对于我的查询,它仅分别搜索"template"和“测试”。请帮助我改善查询。

最佳答案

只需执行一个简单的匹配查询,该查询将对两个词都出现在顶部的结果进行排序,然后对每个词进行排序。
您可以使用此链接https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html添加其他参数

 {
  "query": {
    "bool": {
      "should": [

        {
          "match": {
            "tag": {
              "query": "template testing"
            }
          }
        },

        {
          "match": {
            "title": {
              "query": "template testing"
            }
          }
        },

        {
          "match": {
            "body": {
              "query": "template testing"
            }
         }

        }
        ]
  }
}
}

关于elasticsearch - 在Elasticsearch中搜索而无需标记化关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58951186/

相关文章:

elasticsearch - 为kibana中的每个面板定义不同的查询

ssl - Windows 上的 Kibana SSL PEM 错误

Elasticsearch 查询多个子字段

elasticsearch - 弹性查询仅接受4个字符

elasticsearch - Elasticsearch 未返回附近输入日期的记录

elasticsearch - elasticsearch 5 - 如何查询对象数据类型和嵌套的json数组

elasticsearch - ElasticSearch RollOver索引-为什么别名不能指向多个索引?

elasticsearch - 如何添加到不同的字段值并将其存储在 Elasticsearch python中的另一个字段中( Elasticsearch 字段操作)

elasticsearch - ElasticSearch-将索引还原到较低版本

hadoop - 基于点击流数据的访问者/用户分析?