我运行的是ES 7.17.10,我有一个简单的索引,Map如下:
curl -XPUT -H 'Content-Type: application/json' 127.0.0.1:9200/test_index -d '{
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"field1": { "type": "integer" },
"field2": {
"type": "nested",
"properties": {
"nested1": { "type": "keyword" },
"nested2": { "type": "integer" }
}
}
}
}
}'
当我尝试验证查询字符串时,valid
部分为true,但解释包含错误,这正常吗?
# curl '127.0.0.1:9200/test_index/_validate/query?pretty&explain&q=field1:"test"'
{
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"valid": true,
"explanations": [
{
"index": "test_index",
"valid": true,
"explanation": "MatchNoDocsQuery(\"failed [field1] query, caused by number_format_exception:[For input string: \"test\"]\")"
}
]
}
1条答案
按热度按时间bt1cpqcv1#
validation:验证一个可能开销很大的查询,而不执行它。
说明:返回有关特定文档与查询匹配(或不匹配)的原因的信息。
您的查询有效,查询结果为空集。解释信息告诉你为什么你得到空集,因为你通过一个字符串参数查询一个整数字段。ES可以处理这种情况,不会抛出异常。我认为ES不是强类型的数据库引擎。
另一方面,当索引错误类型的数据时,ES将抛出异常。