简体   繁体   English

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" }

This gets succesfully posted but i wanted to use exists query for usingMissingQuery 这被成功发布,但我想使用现存的查询使用usingMissingQuery

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
}

The exists query is to find documents having a given named field, not for checking the exact value. exists查询用于查找具有给定命名字段的文档,而不是用于检查确切值。 If you have to see if document with _id: 4 exists, you can do it like this: 如果必须查看带有_id: 4文档是否存在,可以这样进行:

POST /ankita-inex/my_type/_search
{
"query" : {

    "bool": {

        "must": {

           "term" : {

               "_id" : "4" 
           }
        }

    }
} }

Or simply like this: 或简单地像这样:

GET /ankita-inex/my_type/4

This will return the document if it exists 这将返回文档(如果存在)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM