Error while searching with unavailable attribute in hibernate search

I have added below attributes in index through this code

 "archetype" : {
            "archetypeId" : "spring-boot",
            "source" : "repository_generation"
 "serviceConfig" : {
            "isExisting" : "false"
  "opsgenie" : {
            "uuid" : "123"

It is working fine if I tried to search like serviceConfig.isExisting:false or archetype.archetypeId:spring-boot or opsgenie.uuid:123

but if tried to search with invalid attribute (unavailable attribute) like serviceConfig.something:123 we are getting below error message for all the invalid attributes

  "errorCode": "Internal",
  "errors": [
      "message": "HSEARCH400611: Invalid type: 'archetype.archetypeId' is a value field, not an object field.",
      "field": null,
      "value": null

Actually error message should include that invalid attribute and not archetype.archetypeId' every time.

Note: I am searching different attribute not archetype one and in hibernate search 5 it was coming empty response for invalid attributes which was expected.

Here is the exception which we are getting while searching:

SearchException: HSEARCH400611: Invalid type: 'archetype.archetypeId' is a value field, not an object field.

Any idea/thoughts?

What is the code that builds the search query?

Here is the code snippet that causing the issue

final SearchPredicateFactory pf

final List<SearchPredicate> predicates = new ArrayList<SearchPredicate>(filters.size());

 if (filter.getKey().isEmpty()) {
                            .matching(String.join(" + ", filter.getValue()) + "*")

Well that doesn’t help much, unfortunately :slight_smile: What’s the value of simpleQueryFields?

Sorry I forgot to add that , here is


[opsgenie.uuid, zrn, archetype.archetypeId, description, archetype.archetypeId.keyword, archetype.source.keyword, serviceConfig.isExisting, opsgenie.uuid.keyword, archetype.source, status]

filter.getValue() returns below values (which is search string )


This is the cause of your error: archetype.archetypeId.keyword

archetype.archetypeId is a value field (not an object field), so archetype.archetypeId.keyword cannot exist as far as Hibernate Search is concerned.

I believe you meant to use simply archetype.archetypeId?

Otherwise, If you were trying to use Elasticsearch’s multi-fields, well… don’t. Hibernate Search doesn’t support them at the moment.

If you really did define multi-fields in the mapping (somehow…), and you really do need to use them during search, then you won’t be able to use the various predicates the Hibernate Search DSL has to offer, and you’ll be limited to native predicates.

Thanks @yrodiere for the information . I wondered how this was working without exception in previous version of hibernate search. Similar fields were populating in HS5

I need to remove keyword from all the below fields or need to use native predicates … Correct?


Hibernate Search 5 was not very strict, it used to accept any field even if it didn’t know about it (and then it would behave strangely, which is why we stopped doing that in 6).
Also, Hibernate Search 5 would not handle dynamic fields explicitly, so most likely you were relying on Elasticsearch’s ability to automatically add fields it didn’t know about. And Elasticsearch adds a keyword sub-field by default in that case.


EDIT: though if you don’t remove keyword, you’ll also need to find a way to define the keyword sub-field on archetype.archetypeId, opsgenie.uuid, etc. Your current Hibernate Search mapping doesn’t define the keyword sub-field, and due to how Hibernate Search 6 works, Elasticsearch won’t add it automatically like it did with Hibernate Search 5. Changing that might prove a bit difficult.

So to sum up, you’re better off removing .keyword :slight_smile:

Thanks @yrodiere :slight_smile: - We are at final stage of migration (HS 5 to HS 6) so you will get few more questions from me if any help is needed.