mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#744 - ElasticSearch - isEmpty() expression needs to have outer not:{} negation to work as per ..
This commit is contained in:
@@ -157,4 +157,14 @@ public interface DocQueryContext {
|
||||
* End nested path expressions.
|
||||
*/
|
||||
void endNested() throws IOException;
|
||||
|
||||
/**
|
||||
* Start a not wrapping an expression.
|
||||
*/
|
||||
void startNot() throws IOException;
|
||||
|
||||
/**
|
||||
* End a not wrapper.
|
||||
*/
|
||||
void endNot() throws IOException;
|
||||
}
|
||||
|
||||
@@ -16,15 +16,38 @@ class IsEmptyExpression extends AbstractExpression {
|
||||
|
||||
private final String propertyPath;
|
||||
|
||||
private String nestedPath;
|
||||
|
||||
IsEmptyExpression(String propertyName, boolean empty) {
|
||||
super(propertyName);
|
||||
this.empty = empty;
|
||||
this.propertyPath = SplitName.split(propertyName)[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nestedPath(BeanDescriptor<?> desc) {
|
||||
if (empty) {
|
||||
// capture the nestedPath as we want to put wrap
|
||||
// a NOT around the outer of the nested path exists
|
||||
this.nestedPath = propertyNestedPath(propName, desc);
|
||||
return null;
|
||||
} else {
|
||||
return super.nestedPath(desc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.writeExists(!empty, propName);
|
||||
if (nestedPath == null) {
|
||||
context.writeExists(!empty, propName);
|
||||
} else {
|
||||
// wrap NOT around the outside of nested path exists expression
|
||||
context.startNot();
|
||||
context.startNested(nestedPath);
|
||||
context.writeExists(empty, propName);
|
||||
context.endNested();
|
||||
context.endNot();
|
||||
}
|
||||
}
|
||||
|
||||
public final String getPropName() {
|
||||
|
||||
Reference in New Issue
Block a user