我想匹配特定文本,因此我使用Match_phrase选项,在我的映射中,默认情况下不会分析某些字段,分析器将是标准的,因此我在match_phrase查询中传递了分析器字段。
当我使用以下查询时,它显示错误:
POST data/_search
{ "size":50,
"query":{
"bool":{
"must":[
{
"term":{
"region":"USA"
}},
{
"match_phrase":{
"university":"University of michigan",
"analyzer": "standard"
}
},
{
"match_phrase":{
"games":"football and basketball",
"analyzer": "standard"
}
}
]
}
}
}
错误是:
"error": {
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "[match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?",
"index": "data",
"line": 13,
"col": 3
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "data",
"node": "9pSi8WYdRRuVrmLjWoGqcg",
"reason": {
"type": "query_parsing_exception",
"reason": "[match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?",
"index": "data",
"line": 13,
"col": 3
}
}
]
},
"status": 400
}
当我在match_phrase字段中删除分析器时,它工作正常。 我可以知道问题出在哪里吗?
由于
答案 0 :(得分:0)
所以而不是:
"match_phrase":{
"university":"University of michigan",
"analyzer": "standard"
}
你应该这样做:
"match_phrase":{
"university":{
"query": "University of michigan",
"analyzer": "standard"
}
}