Skip to content

Commit

Permalink
Merge pull request #314 from Sreejit-K/#789-native-search-issue
Browse files Browse the repository at this point in the history
Native search multiple filters fix 1.0
  • Loading branch information
challabeehyv authored May 6, 2024
2 parents 1dca387 + e539ef1 commit b867336
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import dev.sunbirdrc.registry.middleware.util.Constants;
import dev.sunbirdrc.registry.util.ReadConfigurator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.BiPredicate;

Expand Down Expand Up @@ -66,8 +68,12 @@ private GraphTraversal<Vertex, Vertex> getFilteredResultTraversal(

FilterOperators operator = filter.getOperator();
String path = filter.getPath();
if (path != null) {
resultGraphTraversal = resultGraphTraversal.outE(path).inV();
List<String> subPaths = path != null
? Arrays.asList(path.split("\\."))
: new ArrayList<>();
// Traverse into the sub paths
for (String subPath : subPaths) {
resultGraphTraversal = resultGraphTraversal.outE(subPath).inV();
}

switch (operator) {
Expand Down Expand Up @@ -135,7 +141,11 @@ private GraphTraversal<Vertex, Vertex> getFilteredResultTraversal(
resultGraphTraversal = resultGraphTraversal.has(property, P.eq(genericValue));
break;
}

// traverse back to the parent
Collections.reverse(subPaths);
for (String subPath : subPaths) {
resultGraphTraversal = resultGraphTraversal.inE(subPath).outV();
}
}
}
return resultGraphTraversal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ default void addToFilterList(String path, JsonNode inputQueryNode, List<Filter>
String operatorStr = entryValMap.getKey();

if (entryValMap.getValue().isObject()) {
addToFilterList(entry.getKey(), entryVal, filterList);
// accumulating the path as it goes deep in to the heirarachy if nested separating each level by a '.'
String currpath = path == null ? entry.getKey() : path + "." + entry.getKey();
addToFilterList(currpath, entryVal, filterList);
} else {
Object value = null;
if (entryValMap.getValue().isArray()) {
Expand Down

0 comments on commit b867336

Please sign in to comment.