2017-01-06 61 views
0
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" } 

這被成功地張貼,但我想用存在查詢usingMissingQueryElasticSearch- [存在]查詢沒有彈性搜索支持2.3

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 
} 

回答

0

exists查詢是要找到具有給定命名文件字段,而不是用於檢查確切的值。如果你必須看到,如果有_id: 4文件存在,你可以做這樣的:

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

    "bool": { 

     "must": { 

      "term" : { 

       "_id" : "4" 
      } 
     } 

    } 
} } 

或者乾脆像這樣:

GET /ankita-inex/my_type/4 

如果存在

+0

有了這個這將返回文檔文件如何使用MissingQuery進行彈性saerch 2.3。如果有任何示例 –

+0

你想用MissingQuery實現什麼? – Val

+0

其實我是從彈性搜索1.4.3升級到彈性搜索2.3.5的應用程序。現在Elastic Saerch已經刪除了所有的FilterClasses並將它合併到Query.So中,因此我想要這個行的替代API MissingFilterBuilder incProductsEmptyFilter = FilterBuilders.missingFilter(「 missingfilter「); –