Skip to content

Commit 13a2fce

Browse files
committed
Re-added the logic to move to the last where - except put it only on the first where so it clears out the excess bool -> must -> bool -> must, but doesn't cause problems later.
1 parent 7657a08 commit 13a2fce

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/main/java/org/nlpcn/es4sql/query/maker/FilterMaker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class FilterMaker extends Maker {
1919
*/
2020
public static BoolFilterBuilder explan(Where where) throws SqlParseException {
2121
BoolFilterBuilder boolFilter = FilterBuilders.boolFilter();
22+
while (where.getWheres().size() == 1) {
23+
where = where.getWheres().getFirst();
24+
}
2225
new FilterMaker().explanWhere(boolFilter, where);
2326
return boolFilter;
2427
}

src/test/resources/expectedOutput/search_spatial_explain.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@
66
"filter" : {
77
"bool" : {
88
"must" : {
9-
"bool" : {
10-
"must" : {
11-
"geo_shape" : {
12-
"place" : {
13-
"shape" : {
14-
"type" : "polygon",
15-
"coordinates" : [ [ [ 102.0, 2.0 ], [ 103.0, 2.0 ], [ 103.0, 3.0 ], [ 102.0, 3.0 ], [ 102.0, 2.0 ] ] ]
16-
},
17-
"relation" : "intersects"
18-
},
19-
"_name" : null
20-
}
21-
}
9+
"geo_shape" : {
10+
"place" : {
11+
"shape" : {
12+
"type" : "polygon",
13+
"coordinates" : [ [ [ 102.0, 2.0 ], [ 103.0, 2.0 ], [ 103.0, 3.0 ], [ 102.0, 3.0 ], [ 102.0, 2.0 ] ] ]
14+
},
15+
"relation" : "intersects"
16+
},
17+
"_name" : null
2218
}
2319
}
2420
}

0 commit comments

Comments
 (0)