I annotate a field of an @Indexed class with two analyzers.
Now I use following query:
When I use Lucene as backend it works.
When I use Elasticsearch as backend i get following exception:
Breakpointing in com.google.gson.JsonArray.getAsString(JsonArray.java:226) it turns out that this.elements has size of 2. When I add a third @Field annotation, this.elements is 3. When I remove a field, this.elements is 1 and it works.
What I can tell you is this shouldn't work, even with Lucene:
You need to give a different name to each field:
Now the fact that duplicate fields work (or at least seems to work) with Lucene is a problem... But adding an exception would break backward compatibility, so I'm inclined to leave it as is. Duplicate fields are forbidden in Hibernate Search 6 already.
Oh, and regarding the exception you're getting at projection time, it's expected: projections on multi-valued fields are not supported in Hibernate Search 5. It's going to be supported in Hibernate Search 6.0.0.Beta9 (). It may seem like it works with Lucene in Hibernate Search 5, but it doesn't: you only get the first value ()
Thank you for your answer. You’re right, that is no bug. What I’m doing now is to give each @Field another name and search for it using