我使用以下查询:
{
"from": 0,
"size": 10,
"_source": {
"exclude": ["Content"]
},
"query": {
"query_string": {
"query": "(Content:ربنا)",
"default_operator": " AND "
}
},
"highlight": {
"pre_tags": ["<tag1>"],
"post_tags": ["</tag1>"],
"fields": {"*": {}}
}
}
但出现错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "No enum constant org.elasticsearch.index.query.Operator. AND "
}
],
"type": "illegal_argument_exception",
"reason": "No enum constant org.elasticsearch.index.query.Operator. AND "
},
"status": 400
}
如何解决此错误?
答案 0 :(得分:1)
利用以下查询。您的"default_operator"
必须为AND
(无空格),而在您的查询中,则为" AND "
(有空格)。因此,错误。
{
"from": 0,
"size": 10,
"_source": {
"exclude": ["Content"]
},
"query": {
"query_string": {
"query": "(Content:ربنا)",
"default_operator":"AND"
}
},
"highlight": {
"pre_tags": ["<tag1>"],
"post_tags": ["</tag1>"],
"fields": {"*": {}}
}
}
希望有帮助!