steffenvan commented on code in PR #1646:
URL: https://github.com/apache/jackrabbit-oak/pull/1646#discussion_r1727161273
##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticRequestHandler.java:
##########
@@ -224,6 +226,61 @@ public BoolQuery.Builder baseQueryBuilder() {
return bqb;
}
+ public Optional<KnnQuery> similarityQuery(@NotNull String text,
List<PropertyDefinition> sp) {
+ if (!sp.isEmpty()) {
+ LOG.debug("generating similarity query for {}", text);
+ NodeState targetNodeState = rootState;
+ for (String token : PathUtils.elements(text)) {
+ targetNodeState = targetNodeState.getChildNode(token);
+ }
+ if (!targetNodeState.exists()) {
+ throw new IllegalArgumentException("Could not find node " + text);
+ }
+ for (PropertyDefinition propertyDefinition : sp) {
+ ElasticPropertyDefinition pd = (ElasticPropertyDefinition)
propertyDefinition;
+ String propertyPath = PathUtils.getParentPath(pd.name);
+ String propertyName = PathUtils.getName(pd.name);
+ NodeState tempState = targetNodeState;
+ for (String token : PathUtils.elements(propertyPath)) {
Review Comment:
Could breaking on an empty token break anything? Does it always leave
`tempState` in a desirable state?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]