Hi everyone,
I’ve got a use where I need to override an index definition. The interface :
public interface ISearchableEntity {
default String getTypeLabel() {
return null;
}
}
First class :
public class Acte implements ISearchableEntity {
@Transient
@FullTextField(name = TYPE_LABEL, analyzer = "standard", searchable = Searchable.YES)
@KeywordField(name = TYPE_LABEL_SORT, sortable = Sortable.YES, aggregable = Aggregable.YES)
@IndexingDependency(
derivedFrom = {
@ObjectPath({@PropertyValue(propertyName = Acte_.TYPE_ACTE)})
}
)
@Override
public String getTypeLabel() {
return getTypeActe() != null ? getTypeActe().getLibelle() : null;
}
}
Second (child) class :
public class ActePrive extends Acte {
@Transient
@FullTextField(name = TYPE_LABEL, analyzer = EDGE_NGRAM_2_15, searchAnalyzer = CUSTOM, searchable = Searchable.YES, projectable = Projectable.YES)
@KeywordField(name = TYPE_LABEL_SORT, sortable = Sortable.YES)
@IndexingDependency(
derivedFrom = {
@ObjectPath({@PropertyValue(propertyName = ActePrive_.ACTE_DISTANT)})
})
@Override
public String getTypeLabel() {
String searchLabel = "AAE";
if (Boolean.TRUE.equals(getActeDistant())) {
searchLabel = "AAE à distance - Instrumentaire";
}
return searchLabel;
}
}
As you can see, the definition is not the same, also for @IndexingDependency. But I can’t mass index code like this because the index names TYPE_LABEL and TYPE_LABEL_SORT are duplicated (which is forbidden)