Fetching a sum from a subtree

Gespeichert von pterodactylus42 am

Imagine you have a domain-object which is organized in a tree structure. Additionally there are detached objects that reference a part of this structure. Now you need to collect some value from the referenced portion of the tree. You can identify the TreeOrganizedObjects by their UUID. Here is how you can do it in Java:

 

 

Usage of BooleanQuery and TermsQuery in Lucene Search

Gespeichert von pterodactylus42 am

When dealing with entities that have many references, you might encounter the BooleanQuery.maxClauseCount which is 1024 by default. This value is already pretty high. But if a query exceeds this value, you should be aware that this is a warning indicator for your performance. 

A TermsQuery might be more appropriate in this case, looking somewhat like

 

result = result.filter(f.terms().field("entity_id").matchingAny(idList.stream().map(idToSearch -> String.valueOf(idToSearch)).collect(Collectors.toList())));