2017-02-24 46 views
0

我試圖找到所有不包含字段'open_location'的結果。我正在使用下面的代碼。但它給了我打印結果的錯誤。該錯誤是, parsing_exception:無[查詢]對[過濾]parsing_exception:沒有[查詢]註冊爲[已過濾]

我已經看到了我的解決這個問題, Best way to check if a field exist in an Elasticsearch document

註冊請幫我...

$index_name=$db_name.'_temp_traking'; 

    $para= [ 
     'index' => $index_name, 
     'type' => $index_name, 
     'body' => [ 
      'query' => [ 
       'filtered' => [ 
        'filter' => [ 
         'bool' => [ 
          'must_not' => [ 
           'missing' => [ 
            'field' => 'open_location' 
           ] 
          ] 
         ] 
        ] 
       ] 
      ] 
     ] 
    ]; 
    $response = $client->search($para); 
+0

其中的彈性版本您使用的? – paqash

+0

彈性版本5 – Avishake

+0

您是否使它工作? – paqash

回答

1

過濾後的查詢已棄用並在Elastic 5中刪除,我猜是你正在使用的。此外,你說你正在尋找不包含該字段的文檔,但是你的代碼表明它不能'丟失'。

如果你需要的領域不存在,試試這個:

"query": { 
     "bool": { 
      "must_not": { 
       "exists": { 
        "field": "open_location" 
       } 
      } 
     } 
    } 
相關問題