简体   繁体   English

Elasticsearch:在query_string中使用字段分析器

[英]Elasticsearch: Using of field analyser in query_string

I just want to do a query_string using the analyzer of each field and not one for all fields 我只想使用每个字段的分析器来做一个query_string,而不是所有字段的一个

Do i have to specify all fields like 我是否需要指定所有字段,例如

GET /_search
{
    "query": {
        "query_string" : {
            "fields" : ["content", "name", ...],
            "query" : "this AND that"
        }
    }
}

Is there a solution ? 有解决方案吗?

Thanks 谢谢

First of all, _all is deprecated as of 6.0. 首先, _all从6.0开始不推荐使用。 Source: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html 资料来源: https : //www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html

Article suggests to create a custom field which can be analyzed in a way you want and searched against. 文章建议创建一个自定义字段,可以按您想要的方式对其进行分析和搜索。 Sample 样品

PUT my_index
{
  "mappings": {
    "_doc": {
      "properties": {
        "first_name": {
          "type": "text",
          "copy_to": "fake_all" 
        },
        "last_name": {
          "type": "text",
          "copy_to": "fake_all" 
        },
        "fake_all": {
          // Here you can define analyzer you want
          // And use this field four your query_string query
          "type": "text"
        }
      }
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM