Parse Exception while executing has_child query in Embedded Elastic Search Server

Hi,

I am getting the following exception while executing a has_child query in Embedded Elastic Search Server.

	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:526)
	at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:502)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:409)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:382)
	at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:323)
	at pan.apps.canary.historic_tag_manager.es.TagESManager.searchES(TagESManager.java:102)
	... 25 more
	Suppressed: org.elasticsearch.client.ResponseException: POST http://localhost:9205/malware/sample/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&search_type=dfs_query_then_fetch&batched_reduce_size=512: HTTP/1.1 400 Bad Request
{"error":{"root_cause":[{"type":"parsing_exception","reason":"no [query] registered for [has_child]","line":1,"col":87}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"dfs","grouped":true,"failed_shards":[{"shard":0,"index":"test","node":"6lyIguURRr6xfze5TFvDAA","reason":{"type":"parsing_exception","reason":"no [query] registered for [has_child]","line":1,"col":87}}]},"status":400}
		at org.elasticsearch.client.RestClient$1.completed(RestClient.java:354)
		at org.elasticsearch.client.RestClient$1.completed(RestClient.java:343)
		at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)
		at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
		at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436)
		at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326)
		at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)
		at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
		at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
		at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
		at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
		at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
		at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
		at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
		at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
		at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
		at java.lang.Thread.run(Thread.java:748)

This happens only while using an embedded server.
The following is the query used.

  "bool": {
    "filter": {
      "bool": {
        "must": [
          {
            "bool": {
              "must_not": {
                "has_child": {
                  "type": "sample_plus",
                  "filter": {
                    "terms": {
                      "tag": [
                        "abc"
                      ]
                    }
                  }
                }
              }
            }
          },
          {
            "bool": {
              "filter": {
                "term": {
                  "sample_id": "12345678"
                }
              }
            }
          }
        ]
      }
    }
  }
}```

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

Which version is your server?

in Embedded Elastic Search Server

You can not run elasticsearch embedded. Read this blog post.

Hi

Thank you for the feedback. I formatted the post.

I read the blog and totally understand why an embedded server is not supported.

But for unit tests and integration tests an embedded server comes in handy and seems like a better and useful option.

To answer your question, the elastic search version I am using is 5.6.4.

Also would you be able to share any embedded server equivalent which I can use to run a few integration tests in my application? My application uses RestHighLevelClient to interact with elastic search. Please do let me know if you need any more details.

To run integration tests (not unit tests) you would probably prefer running that in something close to a production environment, like a real elasticsearch server instance. I shared some ideas about integration testing in this thread: In memory testing with RestHighLevelClient

Also this sample project shows how to use Elasticsearch Test Classes:

Thank you for your response. I was able to fulfill my requirement using the elastic search maven plugin

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