ElasticSearch- [exists] 查询在弹性搜索 2.3 中不支持
ElasticSearch- [exists] query does not support in elastic search 2.3
POST /ankita-inex/my_type/_bulk
{ "index": { "_id": 1 }}
{ "title": "The quick brown fox" }
{ "index": { "_id": 2 }}
{ "title": "The quick brown fox jumps over the lazy dog" }
{ "index": { "_id": 3 }}
{ "title": "The quick brown fox jumps over the quick dog" }
{ "index": { "_id": 4 }}
{ "title": "Brown fox brown dog" }
这已成功发布,但我想使用现有查询来使用 MissingQuery
GET /ankita-inex/my_type/_search
{
"query" : {
"bool": {
"must": {
"exists" : {
"index" : "4"
}
}
}
} }
{
"error":
{
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "[exists] query does not support [index]",
"index": "ankita-inex",
"line": 6,
"col": 20
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "ankita-inex",
"node": "pbwST3JVSlq3sPqBgWoAVg",
"reason": {
"type": "query_parsing_exception",
"reason": "[exists] query does not support [index]",
"index": "ankita-inex",
"line": 6,
"col": 20
}
}
]
},
"status": 400
}
exists
查询是查找具有给定命名字段的文档,而不是检查确切的值。如果你必须查看带有 _id: 4
的文档是否存在,你可以这样做:
POST /ankita-inex/my_type/_search
{
"query" : {
"bool": {
"must": {
"term" : {
"_id" : "4"
}
}
}
} }
或者像这样:
GET /ankita-inex/my_type/4
这将 return 文档(如果存在)
POST /ankita-inex/my_type/_bulk
{ "index": { "_id": 1 }}
{ "title": "The quick brown fox" }
{ "index": { "_id": 2 }}
{ "title": "The quick brown fox jumps over the lazy dog" }
{ "index": { "_id": 3 }}
{ "title": "The quick brown fox jumps over the quick dog" }
{ "index": { "_id": 4 }}
{ "title": "Brown fox brown dog" }
这已成功发布,但我想使用现有查询来使用 MissingQuery
GET /ankita-inex/my_type/_search
{
"query" : {
"bool": {
"must": {
"exists" : {
"index" : "4"
}
}
}
} }
{
"error":
{
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "[exists] query does not support [index]",
"index": "ankita-inex",
"line": 6,
"col": 20
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "ankita-inex",
"node": "pbwST3JVSlq3sPqBgWoAVg",
"reason": {
"type": "query_parsing_exception",
"reason": "[exists] query does not support [index]",
"index": "ankita-inex",
"line": 6,
"col": 20
}
}
]
},
"status": 400
}
exists
查询是查找具有给定命名字段的文档,而不是检查确切的值。如果你必须查看带有 _id: 4
的文档是否存在,你可以这样做:
POST /ankita-inex/my_type/_search
{
"query" : {
"bool": {
"must": {
"term" : {
"_id" : "4"
}
}
}
} }
或者像这样:
GET /ankita-inex/my_type/4
这将 return 文档(如果存在)