Hey Filip,
Your question looks similar to the one discussed in this thread Searching in nested lists
Overall you want to use a nested structure on your index-embedded and a nested predicate. In particular take a look at the example from that section (it shows how to build a predicate where two fields of a nested object must match the condition for an entity to be included in the results.
The problematic part is that you need to have the map key be a part of the object representing the corresponding value. (using a value extractor for both keys and values won’t work since you’ll just end up having two collections)
So you could try to have something along the next lines instead:
AnObject{
// don't map the map itself
private Map<EnumKey, AnotherObject> anotherObjects;
// have a getter instead that would return a custom object:
@IndexedEmbedded(structure = ObjectStructure.NESTED)
@IndexingDependency(derivedFrom = {
@ObjectPath(@PropertyValue(propertyName = "anotherObjects"))})
List<AnotherObjectsWrapped> getAnotherObjectsWrapped() {
return anotherObjects.entrySet().stream().map( AnotherObjectsWrapped::new ).collect( Collectors.toList() );
}
}
public static class AnotherObjectsWrapped {
@GenericField
EnumKey enumKey;
@IndexedEmbedded
AnotherObject anotherObject;
public BookEntry(Map.Entry<EnumKey,AnotherObject> entry) {
...
}
}