[hibernate-issues] [JIRA] (HSEARCH-3978) Exception when using elasticsearch and multiple analyzers for indexed field in projection query.

Rokko_11 NA (JIRA) jira at hibernate.atlassian.net
Fri Jul 31 06:30:13 EDT 2020


Rokko_11 NA ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A7beb4287-be5a-46de-9792-ca02584abe22 ) *created* an issue

Hibernate Search ( https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiODc5N2FjZWRjYTA1NDA3MWExMGU1MDU3ZmNkZWRjYTUiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HSEARCH-3978?atlOrigin=eyJpIjoiODc5N2FjZWRjYTA1NDA3MWExMGU1MDU3ZmNkZWRjYTUiLCJwIjoiaiJ9 ) HSEARCH-3978 ( https://hibernate.atlassian.net/browse/HSEARCH-3978?atlOrigin=eyJpIjoiODc5N2FjZWRjYTA1NDA3MWExMGU1MDU3ZmNkZWRjYTUiLCJwIjoiaiJ9 ) Exception when using elasticsearch and multiple analyzers for indexed field in projection query. ( https://hibernate.atlassian.net/browse/HSEARCH-3978?atlOrigin=eyJpIjoiODc5N2FjZWRjYTA1NDA3MWExMGU1MDU3ZmNkZWRjYTUiLCJwIjoiaiJ9 )

Issue Type: Bug Affects Versions: 5.11.5.Final Assignee: Unassigned Components: backend-elasticsearch Created: 31/Jul/2020 03:30 AM Labels: search Priority: Minor Reporter: Rokko_11 NA ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A7beb4287-be5a-46de-9792-ca02584abe22 )

Hello,

I annotate a field of an @Indexed class with two analyzers.

   @Field(store = Store.YES, analyzer = @Analyzer(definition = "phonetic" ))
   @Field(store = Store.YES, analyzer = @Analyzer(definition = "ngram" ))
   private String value;

Now I use following query:

FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
Query query = fullTextEntityManager.getSearchFactory()
  .buildQueryBuilder()
  .forEntity(itemClass)
  .get()
  .keyword()
  .onField( "value" )
  .matching(value)
  .createQuery();
FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery(query);
fullTextQuery.setProjection(
  ProjectionConstants.ID,
  ProjectionConstants.OBJECT_CLASS,
  ProjectionConstants.SCORE,
  "value"
);
List< Object []> resultList = fullTextQuery.getResultList();

When I use Lucene as backend it works.

When I use Elasticsearch as backend i get following exception:

Caused by: java.lang.IllegalStateException
	at com.google.gson.JsonArray.getAsString(JsonArray.java:226)
	at org.hibernate.search.elasticsearch.query.impl.PrimitiveProjection.addDocumentField(PrimitiveProjection.java:69)
	at org.hibernate.search.elasticsearch.query.impl.PrimitiveProjection.addDocumentField(PrimitiveProjection.java:43)
	at org.hibernate.search.elasticsearch.query.impl.TwoWayFieldBridgeProjection.convertFieldValue(TwoWayFieldBridgeProjection.java:60)
	at org.hibernate.search.elasticsearch.query.impl.TwoWayFieldBridgeProjection.convertHit(TwoWayFieldBridgeProjection.java:43)
	at org.hibernate.search.elasticsearch.query.impl.QueryHitConverter.convert(QueryHitConverter.java:186)
	at org.hibernate.search.elasticsearch.query.impl.IndexSearcher.convertQueryHit(IndexSearcher.java:138)
	at org.hibernate.search.elasticsearch.query.impl.ElasticsearchHSQueryImpl.queryEntityInfos(ElasticsearchHSQueryImpl.java:233)
	at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.doHibernateSearchList(FullTextQueryImpl.java:240)
	at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.list(FullTextQueryImpl.java:225)
	at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.getResultList(FullTextQueryImpl.java:124)

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

( https://hibernate.atlassian.net/browse/HSEARCH-3978#add-comment?atlOrigin=eyJpIjoiODc5N2FjZWRjYTA1NDA3MWExMGU1MDU3ZmNkZWRjYTUiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-3978#add-comment?atlOrigin=eyJpIjoiODc5N2FjZWRjYTA1NDA3MWExMGU1MDU3ZmNkZWRjYTUiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100140- sha1:33445dc )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200731/670ad0ed/attachment.html 


More information about the hibernate-issues mailing list