Predicate on multiple fields designated by a single label/group name/etc. ("_all", copy_to, ...)

Description

Sometimes it's not practical to explicitly list all the fields one wants to target when searching. Maybe there are lots of them, maybe you just want to target all fields that can be targeted, ...

Some related discussions on the forums:

Elasticsearch offers several solutions to that problem; we should investigate and pick the most appropriate.
In particular:

  • Some queries implicitly target all relevant fields when we don't pass a field name (simple query string in particular)

  • The copy_to attribute in the mapping allows copying the content of a field to another at indexing time : https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html

  • I remember seeing something about an _all field whose content is the content of all other fields? Though I believe it was disabled by default.

Alternatively, we could use our own concept of groups in Hibernate Search:

  • Assign one or more groups to each field.

  • When searching, specify the group name instead of the field name, which will select all fields with that name.

We already need that concept of groups for other features, and will most likely introduce it in , so... two birds with one stone?

The main downside of this alternative solution is that field groups most likely wouldn’t be able to include dynamic fields, since by definition Hibernate Search does not have a full list of those (only Elasticsearch does).

Attachments

2

duplicates

Activity

Show:

Mouhcen April 29, 2024 at 3:48 PM

All right, I see. Thanks for this clarification and specially thanks for your time, I really appreciate it

Marko Bekhta April 29, 2024 at 8:11 AM

So do I need to place @TypeBinding only on the super class ?

Please note that the type binder and other code examples shared in this ticket are not part of the Hibernate Search distribution. If you are trying to achieve something similar, you can implement the binders in a way that better suits your needs.

Looking at the implementation of MultiPropertyBinder – it requires a type Class<T> classT that is used to scan for properties with PropertyFinderCrawler. Hence, you’d want the binder to be applied to the leaf type of your inheritance hierarchy to collect all the properties for that leaf.

Mouhcen April 26, 2024 at 4:30 PM

Hi

Thanks for your reply.

Yes indeed, I placed multiple @TypeBinding on all entities.

So do I need to place @TypeBinding only on the super class ?

Thanks

Marko Bekhta April 26, 2024 at 3:47 PM

Hey ,

From the info you’ve provided I can only assume that you’ve placed multiple @TypeBinding annotations on the same type, which leads to each of them trying to add the ALL field.

Mouhcen April 26, 2024 at 1:13 PM
Edited

Hi,
Thanks for sharing the @MultiPropertyFullTextField utility,

I have implemented it in my projet bu t I’m facing an issue related to duplicate inde:

Context: Hibernate ORM mapping, type 'com.legalsuite.core.model.common.PhysicalPerson', index 'PhysicalPerson', index schema root Failure: org.hibernate.search.util.common.SearchException: HSEARCH600034: Duplicate index field definition: 'ALL'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name. Context: index 'PhysicalPerson', index schema root

 

i have PhysicalPerson and others Entities extends BaseFileEntity

foearch Entity I definied the @TypeBinding(binder = @TypeBinderRef(type = BaseFileEntityBinder.class)) and @TypeBinding(binder = @TypeBinderRef(type = PhysicalPersonBinder.class)) etc … All of thoses binders extends MultiPropertyBinder

In each Entity I have annotated properties for indexing using @MultiPropertyFullTextField(name = "ALL") and @FullTextField(projectable = Projectable.YES)

 

Do you have any idea of what’s wrong ?

Best regards,

Mouhcen

Details

Assignee

Reporter

Components

Fix versions

Priority

Created May 25, 2020 at 10:58 AM
Updated April 29, 2024 at 3:48 PM