Support for copy_to mapping on fields

Are there any plans to support the copy_to mapping directive on fields? Is there any method to achieve the same using available features on 6.0.0.Beta7?

There currently are no plans to support this. It might be added one day (especially if you propose a design and work with us to implement it), but currently there are just too many more urgent things to do.

You generally can get by without this feature by creating one field per property you want to index, and targeting all fields when searching:

List<MyEntity> hits = Search.session(entityManager).search(MyEntity.class)
    .where( f -> f.match().fiels( "field1", "field2", "field3" ).matching( "someText" ) ) 
    .fetchHits( 20 )

If you really need the content of multiple text properties to end up in a single index field, you can either:

  1. Declare a getter that returns a List<String> containing all the data you’re interested in and annotate it with @FullTextField and @IndexingDependency(derivedFrom = ...); see https://docs.jboss.org/hibernate/search/6.0/reference/en-US/html_single/#mapper-orm-reindexing-derivedfrom
  2. Implement a custom type bridge that collects all the data you’re interested in and puts it in a single field; see https://docs.jboss.org/hibernate/search/6.0/reference/en-US/html_single/#mapper-orm-bridge-typebridge

EDIT: Relevant ticket: HSEARCH-3926 Predicate on multiple fields designated by a single label/group name/etc. ("_all", copy_to, …)

1 Like