How to remove invalid document from index

Hello,

I accidently added a document to my index which contains an invalid character. How can I identify and corect/delete the invalid document?

curl http://192.168.2.105:9200/directory/_search?pretty -d'{query:{match_all{}}}'
{
  "error" : {
    "root_cause" : [ {
      "type" : "query_parsing_exception",
      "reason" : "Failed to parse",
      "index" : "directory"
    } ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [ {
      "shard" : 0,
      "index" : "directory",
      "node" : "kvd1OZj1SRCaENPaVX9Yvw",
      "reason" : {
        "type" : "query_parsing_exception",
        "reason" : "Failed to parse",
        "index" : "directory",
        "caused_by" : {
          "type" : "json_parse_exception",
          "reason" : "Unexpected character ('{' (code 123)): was expecting a colon to separate field name and value\n at [Source: [B@14b93ab; line: 1, column: 19]"
        }
      }
    } ]
  },
  "status" : 400
}

Thanks for help in advance!

That snippet you posted is an invalid query. It has one too many trailing }s.

You can delete documents with curl -XDELETE localhost:9200/index/type/id. You can use the search API to find the document to delete.

My mistake!

Thanx a lot for support!!!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.