named_object_not_found_exception while querying ElasticSearch

I am trying to query ElasticSearch using hibernateSearh 6. Following is the Json query which is sent to ElasticSearch. It looks fine as per documentation here :


Howver, getting following Exception with message: HSEARCH400007: Elasticsearch request failed: HSEARCH400090: Elasticsearch response indicates a failure.
Request: POST /employee-read/_search with parameters {from=0, size=10, track_total_hits=true}
Response: 400 'Bad Request' from 'http://localhost:9200' with body 
  "error": {
    "root_cause": [
        "type": "parsing_exception",
        "reason": "unknown query [query]",
        "line": 1,
        "col": 19
    "type": "parsing_exception",
    "reason": "unknown query [query]",
    "line": 1,
    "col": 19,
    "caused_by": {
      "type": "named_object_not_found_exception",
      "reason": "[1:19] unknown field [query]"
  "status": 400

Here are the entities:

@Indexed(index = "employee")
public class Employee {

  @FullTextField(name = "employee_key")
  private String employeeKey;

  @FullTextField(name = "first_name")
  private String firstName;
  @IndexedEmbedded(includeEmbeddedObjectId = true, includeDepth = 2)
  private Address addresses;

public class Address {
  @FullTextField(name = "address_key")
  private String addressKey;

  @FullTextField(name = "street_name")
  private String streetName;


and following is the code to fetch data from Elastic where predicateFunction is: (ElasticsearchSearchPredicateFactory f) -> f.fromJson(queryJson)

SearchSession searchSession = Search.session(entityManager);

            SearchResult<Employee> searchResult =
                    .where(searchPredicateFactory -> {
                        return predicateFunction.apply(searchPredicateFactory);
                    .fetch(Math.toIntExact(page.getOffset()), page.getPageSize());


  • Hibernate Search expects that you'd pass the query itself without the wrapper JSON object. See an example here. So in your case you should pass a: