2016-07-17 13 views
8

すべての一致するドキュメントを削除するネストクエリーを持っていますが、これは400回の不正リクエストです。Elasticsearch DeleteByQueryが機能しない、400の不正なリクエストを取得する

var client = new ElasticClient(); 
     var request = new DeleteByQueryRequest<Type>("my-index") 
     { 
      Query = new QueryContainer(
        new TermQuery 
        { 
         Field = "versionId", 
         Value = "ea8e517b-c2e3-4dfe-8e49-edc8bda67bad" 
        } 
       ) 
     }; 
     var response = client.DeleteByQuery(request); 
     Assert.IsTrue(response.IsValid); 

ありがとうございました。

---------------更新---------------

リクエストボディ

{"query":{"term":{"versionId":{"value":"ea8e517b-c2e3-4dfe-8e49-edc8bda67bad"}}}} 

レスポンスボディセンスプラグインで

{"took":0,"timed_out":false,"_indices":{"_all":{"found":0,"deleted":0,"missing":0,"failed":0}},"failures":[]} 

問合せ:

GET /my-index/type/_search 
{ 
    "query": { 

      "match": { 
      "versionId": "ea8e517b-c2e3-4dfe-8e49-edc8bda67bad" 
      } 

    } 
} 

クエリ応答:

{ 
    "took": 3, 
    "timed_out": false, 
    "_shards": { 
     "total": 5, 
     "successful": 5, 
     "failed": 0 
    }, 
    "hits": { 
     "total": 116, 
     "max_score": 2.1220484, 
     "hits": [] 
... 
}} 

--------------- NESTのQUERY --------------は

DELETE http://localhost:9200/my-index/component/_query?pretty=true 
{ 
    "query": { 
    "term": { 
     "versionId": { 
     "value": "ea8e517b-c2e3-4dfe-8e49-edc8bda67bad" 
     } 
    } 
    } 
} 

Status: 200 
{ 
    "took" : 0, 
    "timed_out" : false, 
    "_indices" : { 
    "_all" : { 
     "found" : 0, 
     "deleted" : 0, 
     "missing" : 0, 
     "failed" : 0 
    } 
    }, 
    "failures" : [ ] 
} 
+0

どのバージョンのElasticsearchをターゲットにしていますか、どのバージョンのNESTを使用していますか? –

答えて

5

それはかもしれないあなたのように聞こえますNEST 2.xと併せてElasticsearch 2.xを使用してください。 Elasticsearch 2.0の一部として、Delete by query was moved out of Elasticsearch core and into a separate pluginをインストールする必要があります。あなたは、再びノードを起動Elasticsearch binディレクトリ

bin/plugin install delete-by-query 

内で次のコマンドを使用してプラグインをインストール期待通りに動作するようになりましたクエリにより削除することができます。

リクエストが失敗した理由の詳細を確認する必要がある場合は、応答の.DebugInformationを調べてリクエストの監査証跡を取得できます。

+0

華麗な、私はそのおかげで束を試みます。 –

+0

Russさん、プラグインのインストール後に試しましたが、response.IsValidはtrueですが、データは削除されません。 –

+0

私はクエリ内の型名について明示的ではありません。一般的なパラメータクラスを除きます。 –

関連する問題