Exception when using elasticsearch and multiple analyzers for indexed field in projection query.

Description

Hello,

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.

Kind regards

Environment

None

Activity

Show:
Yoann Rodière
July 31, 2020, 11:02 AM

Hello,

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.

Yoann Rodière
July 31, 2020, 11:05 AM
Edited

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 ()

Rokko_11 NA
August 4, 2020, 6:29 AM

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

Assignee

Yoann Rodière

Reporter

Rokko_11 NA

Labels

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Affects versions

Priority

Minor
Configure