我只想使用每个字段的分析器来执行一个query_string,而不是对所有字段使用一个分析器
我是否必须指定所有字段
GET /_search
{
"query": {
"query_string" : {
"fields" : ["content", "name", ...],
"query" : "this AND that"
}
}
}
有解决方案吗?
谢谢
答案 0 :(得分:0)
首先,_all
从6.0开始不推荐使用。来源:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html
文章建议创建一个自定义字段,可以按您想要的方式对其进行分析并对其进行搜索。样本
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"
}
}
}
}
}