Search_analyzer是索引时间的param,所以如果你想为同义词的字段设置它:
{
"settings": {
"index" : {
"analysis" : {
"analyzer" : {
"synonym" : {
"tokenizer" : "whitespace",
"filter" : ["synonym"]
}
},
"filter" : {
"synonym" : {
"type" : "synonym",
"synonyms_path" : "analysis/synonym.txt"
}
}
}
}
}, "mappings" : {
"properties" : {
"description" : {
"type" : "text",
"analyzer": "synonym",
"search_analyzer": "standard"
},
"content" : {
"type" : "text",
"analyzer": "synonym",
"search_analyzer": "standard",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
通过这种方式,您已经为查询时间设置了默认分析器。所以你现在可以通过这种方式执行multimatch 查询:
{
"query": {
"multi_match" : {
"query": "bread cereal",
"type": "cross_fields",
"fields": [
"description",
"content"
],
"operator": "and"
}
}
}
如果您没有在索引时为这些字段设置特定的search_analyzer,则在查询时使用用于指示的相同分析器。如果您没有在索引时间上设置search_analyzer,您可以force to use a specific analyzer at query time 将analyzer 参数放入查询中:
{
"query": {
"multi_match" : {
"query": "bread cereal",
"analyzer" : "standard",
"type": "cross_fields",
"fields": [
"description",
"content"
],
"operator": "and"
}
}
}