2
votes

I have wrote own in-memory ElasticSearch server in version 5.1.1. It works correctly for adding of documents but fails on removing.

Maven dependencies:

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.plugin</groupId>
        <artifactId>transport-netty4-client</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
    </dependency>

Map of settings for node:

    settingsMap.put("node.name", nodeName);
    settingsMap.put("path.conf", "target");
    settingsMap.put("path.data", "target");
    settingsMap.put("path.logs", "target");
    settingsMap.put("path.home", "target");
    settingsMap.put("http.type", "netty4");
    settingsMap.put("http.port", httpPort);
    settingsMap.put("transport.tcp.port", httpTransportPort);
    settingsMap.put("transport.type", "netty4");
    settingsMap.put("action.auto_create_index", "false");

Method for deleting many documents in once:

public boolean deleteType() throws IOException, CustomResponseException {
    String query = "{\n" + "  \"query\": {\n" + "    \"match_all\": {}\n" + "  }\n" + "}";
    HttpEntity entity = new NStringEntity(query, ContentType.APPLICATION_JSON);
    Response indexResponse = restClient.performRequest("POST",
            "/" + this.getIndex() + "/" + this.getType() + "/_delete_by_query?conflicts=proceed",
            Collections.<String, String>emptyMap(), entity);
    return processStatusCode(indexResponse.getStatusLine()) == 200;
}

When I run tests, I get error:

org.elasticsearch.client.ResponseException: POST http://localhost:9205/testindexer/indexer/_delete_by_query?conflicts=proceed: HTTP/1.1 400 Bad Request {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/testindexer/indexer/_delete_by_query] contains unrecognized parameter: [conflicts]"}],"type":"illegal_argument_exception","reason":"request [/testindexer/indexer/_delete_by_query] contains unrecognized parameter: [conflicts]"},"status":400}

Additionally when I run it without conflicts proceeding I'm getting as an answer that document is created. Why is it working differently than in documentation for this version?

Here is status of my node:

{
  "name" : "indexernode",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "trP6UQg1SMKVyfR0qTEjYw",
  "version" : {
    "number" : "5.1.1",
    "build_hash" : "5395e21",
    "build_date" : "2016-12-06T12:36:15.409Z",
    "build_snapshot" : false,
    "lucene_version" : "6.3.0"
 },
 "tagline" : "You Know, for Search"
}
1

1 Answers

1
votes

Side note: This is not the correct way to delete all index data, but I guess you are aware of that.

Can you try to supply the parameter in the restclient as a parameter and not as part of the URL, jsut to make sure that this is not the issue.

I think the main issue here is, that you said you are running your own embedded version of elasticsearch (is this what you mean with in memory). Have you checked that the reindex plugin is installed with that version?