No search results in multi tenancy mode for tenants with hyphens

Description

We recently updated Hibernate Search from 5.10.5 to 5.11.0/1. During the last update of our application, we altered index mappings and dropped the index. On startup, the index was created and re-indexing worked as expected. But executing any search for a tenant with a hyphen ("-") in its name returns no results.

What we're seeing is that Hibernate 5.10.5 generates the field __HSearch_TenantId like this:

while beginning from Hibernate Search 5.11.0, index definition is as follows:

The query executed by Hibernate Search looks like this

and will never return any result.

In our opinion, either the index definition of field __HSearch_TenantId has to be reverted to the original behaviour, or the generated filter query by the FullTextEntityManager should use the keyword field.

Environment

Elasticsearch 6.3.1
Hibernate 5.4.1
Hibernate Search 5.11.x

Activity

Show:
Yoann Rodière
April 3, 2019, 1:08 PM

This is typically what happens when you use an indexing management strategy that does not generate nor check the schema, such as create or none. Hibernate Search sent to Elasticsearch something that didn't fit the schema, and Elasticsearch automatically guessed what the schema should be. Like often, it guessed wrong: it's really hard to know the schema from just a value.

Why I'm sure of that:

  1. Hibernate Search does not create "fields" in Elasticsearch properties, except in very specific cases (faceting)

  2. We really didn't change much in the Elasticsearch backend between 5.10 and 5.11, and nothing related to multi-tenancy IIRC.

The solution in your case would be to drop the indexes, start Hibernate Search with a strategy that creates the indexes and their schema (create should be safe), and only then reindex.

I will close this ticket because it's not a bug, or at least not the one described here, but feel free to open a question on stackoverflow (tag hibernate-search) or on our Discourse instance: I'll be glad to help.

Mirko Adebahr
April 3, 2019, 2:46 PM

Thank you, your comment was very helpful and led to the real problem: We deleted the index, then obviously our re-indexing job was running (using FullTextEntityManager::index) which caused Elasticsearch to use type text as a default, as you suspected.

Assignee

Yoann Rodière

Reporter

Mirko Adebahr

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Affects versions

Priority

Critical
Configure