Hello! I have a problem and I can’t solve it.
There is a Product entity which contains the next indexing field:
@GenericField @ElementCollection(fetch = FetchType.LAZY) @CollectionTable(name = "t_product_pilots", schema = DbSchema.KKK, joinColumns = @JoinColumn(name = "product_id")) @Column(name = "pilot_id", nullable = false) private Set<Long> pilots = new HashSet<>();
pilots
contains IDs of Pilot entity.
The problem is how I can create an additional field/getter in Product entity which contains some info about Pilots and I can use it for searching.
Here is what I tried to do but it doesn’t work correctly:
@IndexedEmbedded(name = "pilot_data", includePaths = { "name", "description", "effects", "problems" }) private List<Pilot> getPilotsForIndexing(@Autowired PilotRepository repo) { return repo.findAllById(pilots); }
I want the next structure in indexing document:
... "pilots": [1, 4, 5], ... "pilot_data": [ "name": "123", "description": "desc", "effects": "zero", "problems": "no problem" ], ...
And after that I want to search for it like this:
predicate.should(factory.wildcard() .field("pilot_data.name").boost(3) .field("pilot_data.description").boost(2) ... );