Fetching a sum from a subtree

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

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())));
 

Dijkstra

/**
* Kürzeste Wege in einem Graphen ermitteln
*
* @author neubauer 03.12.2022 create
*/
public class Dijkstra
{
//    grün = leere Menge
//    gelb = ausgangselement
//    distanz von v = 0
//    so lange menge der gelben elemente nicht leer ist
//        wähle das element aus den gelben elementen mit der geringsten Entfernung als w