This is an automated email from the ASF dual-hosted git repository.
fortino pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6331a5a979 OAK-11508: [oak-search-elastic] is null / is not null
queries should resolve the field name (#2101)
6331a5a979 is described below
commit 6331a5a9794529d31f2e7735df5f58b8abfab582
Author: Fabrizio Fortino <[email protected]>
AuthorDate: Thu Feb 20 14:01:56 2025 +0100
OAK-11508: [oak-search-elastic] is null / is not null queries should
resolve the field name (#2101)
* OAK-11508: [oak-search-elastic] is null / is not null queries should
resolve the field name
* OAK-11508: [oak-search-elastic] is null / is not null queries should
resolve the field name
---
.../oak/plugins/index/elastic/query/ElasticRequestHandler.java | 9 ++++-----
.../oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java | 8 ++++----
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticRequestHandler.java
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticRequestHandler.java
index 5b842c5830..c7d8c55b6b 100644
---
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticRequestHandler.java
+++
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticRequestHandler.java
@@ -901,18 +901,17 @@ public class ElasticRequestHandler {
}
private Query createQuery(String propertyName, Filter.PropertyRestriction
pr, PropertyDefinition defn) {
- int propType = FulltextIndex.determinePropertyType(defn, pr);
+ final String field =
elasticIndexDefinition.getElasticKeyword(propertyName);
if (pr.isNullRestriction()) {
- return Query.of(q -> q.bool(b -> b.mustNot(m -> m.exists(e ->
e.field(propertyName)))));
+ return Query.of(q -> q.bool(b -> b.mustNot(m -> m.exists(e ->
e.field(field)))));
}
if (pr.isNotNullRestriction()) {
- return Query.of(q -> q.exists(e -> e.field(propertyName)));
+ return Query.of(q -> q.exists(e -> e.field(field)));
}
- final String field =
elasticIndexDefinition.getElasticKeyword(propertyName);
-
Query in;
+ int propType = FulltextIndex.determinePropertyType(defn, pr);
switch (propType) {
case PropertyType.DATE: {
in = newPropertyRestrictionQuery(field, pr, value ->
parse(value.getValue(Type.DATE)).getTimeInMillis());
diff --git
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java
index caf3cb4739..f733b0f120 100644
---
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java
+++
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java
@@ -86,25 +86,25 @@ public class ElasticIndexQueryCommonTest extends
IndexQueryCommonTest {
@Override
public String getContainsValueForInequalityQuery_native() {
- return
"\"filter\":[{\"term\":{\":ancestors\":{\"value\":\"/test\"}}},{\"exists\":{\"field\":\"propa\"}},"
+
+ return
"\"filter\":[{\"term\":{\":ancestors\":{\"value\":\"/test\"}}},{\"exists\":{\"field\":\"propa.keyword\"}},"
+
"{\"bool\":{\"must_not\":[{\"term\":{\"propa.keyword\":{\"value\":\"bar\"}}}]";
}
@Override
public String
getContainsValueForInequalityQueryWithoutAncestorFilter_native() {
- return "\"filter\":[{\"exists\":{\"field\":\"propa\"}},{\"bool\":" +
+ return
"\"filter\":[{\"exists\":{\"field\":\"propa.keyword\"}},{\"bool\":" +
"{\"must_not\":[{\"term\":{\"propa.keyword\":{\"value\":\"bar\"}}}]";
}
@Override
public String getContainsValueForEqualityInequalityCombined_native() {
return
"\"filter\":[{\"term\":{\":ancestors\":{\"value\":\"/test\"}}},{\"term\":{\"propb.keyword\":{\"value\":\"world\"}}},"
+
-
"{\"exists\":{\"field\":\"propa\"}},{\"bool\":{\"must_not\":[{\"term\":{\"propa.keyword\":{\"value\":\"bar\"}}}]";
+
"{\"exists\":{\"field\":\"propa.keyword\"}},{\"bool\":{\"must_not\":[{\"term\":{\"propa.keyword\":{\"value\":\"bar\"}}}]";
}
@Override
public String getContainsValueForNotNullQuery_native() {
- return
"\"filter\":[{\"term\":{\":ancestors\":{\"value\":\"/test\"}}},{\"exists\":{\"field\":\"propa\"}}]";
+ return
"\"filter\":[{\"term\":{\":ancestors\":{\"value\":\"/test\"}}},{\"exists\":{\"field\":\"propa.keyword\"}}]";
}
@Override