Skip to content

Commit

Permalink
better elastic query
Browse files Browse the repository at this point in the history
  • Loading branch information
david-blasby committed Sep 26, 2024
1 parent dbf1eb1 commit dad79a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ private ResponseEntity<Void> collectionsCollectionIdItemsGetAsHtml(
String collectionFilter = collectionService.retrieveCollectionFilter(source, false);
String query = recordsEsQueryBuilder
.buildQuery(q, externalids, bbox, startindex, limit, collectionFilter, sortby, null);

EsSearchResults results = new EsSearchResults();
try {
results = proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.elasticsearch.geometry.Rectangle;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.GeoShapeQueryBuilder;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
Expand Down Expand Up @@ -141,11 +142,15 @@ public String buildQuery(
}
}

String filterQueryString = configuration.getQueryFilter();
String filterQueryString = "(" + configuration.getQueryFilter() + ")";
if (StringUtils.isNotEmpty(collectionFilter)) {
filterQueryString += " " + collectionFilter;
filterQueryString += " (" + collectionFilter + ")";
}
boolQuery.filter(QueryBuilders.queryStringQuery(filterQueryString));

var bbQuery = QueryBuilders.queryStringQuery(filterQueryString);
bbQuery.defaultOperator(Operator.AND);
boolQuery.filter(bbQuery);

sourceBuilder.query(boolQuery);
sourceBuilder.trackTotalHits(configuration.getTrackTotalHits());
log.debug("OGC API query: {}", sourceBuilder.toString());
Expand Down

0 comments on commit dad79a6

Please sign in to comment.