How to configure type name or filter by request type with Elasticsearch integration?

I am using Hibernate Search with Elasticsearch integration with versions 5.8.2 and 5.6 respectively.

Let's say I have 2 applications that use the same database, and I want to search for a Person object. Both applications will update indexes, but only one of them will read.

Since Hibernate Search uses fully qualified class names for type s by default, I get two different types for the same object, for example:

Person β†’ com.example.x.Person

Person β†’ com.example.y.Person

In the application, I perform a search when building a search query, Hibernate Search automatically adds a filter query for type , for example:

 "filter": { "type": {"value": "com.example.x.Person"} } 

Thus, the search results do not contain entries from the type com.example.y.Person .

Is there a way to customize type names?

Or, is there a way to disable / configure the added filter request?

+5
source share
1 answer

You cannot do it now.

Oddly enough, we just had a very similar question a few days ago: Override Elasticsearch _type in Hibernate Search .

My advice is this: if it is the same entity, you should extract it into a common jar and use the same entity in both your applications (if you cannot extract it, you can still use the same package, but I would recommend removing it so that you are sure that it is exactly the same).

0
source

Source: https://habr.com/ru/post/1273169/


All Articles