Skip to content

Commit

Permalink
Attempt fix csw (#275)
Browse files Browse the repository at this point in the history
* replace only %s

* feat: replace query with {@}

* feat: replace query with {@}
  • Loading branch information
f-necas authored Jan 12, 2024
1 parent 417d36b commit 2ea70fe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public Element search(ServiceContext context, int startPos, int maxRecords,

try {
String filterQueryString = esFilterBuilder.build(context, "metadata", false, node);
String jsonQuery = String.format(elasticSearchQuery, filterQueryString);
String jsonQuery = StringUtils.replace(elasticSearchQuery, "{@}", filterQueryString);

ObjectMapper objectMapper = new ObjectMapper();
esJsonQuery = objectMapper.readTree(jsonQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class CswFilter2Es extends AbstractFilterVisitor {
" \"must\": [\n" +
" %s\n" +
" ]\n" +
" ,\"filter\":{\"query_string\":{\"query\":\"%s\"}}}"; //, "minimum_should_match" : 1
" ,\"filter\":{\"query_string\":{\"query\":\"{@}\"}}}"; //, "minimum_should_match" : 1
private static final String TEMPLATE_OR = " {\"bool\": {\n" +
" \"should\": [\n" +
" %s\n" +
Expand All @@ -77,7 +77,7 @@ public class CswFilter2Es extends AbstractFilterVisitor {
" \"should\": [\n" +
" %s\n" +
" ]\n" +
" ,\"filter\":{\"query_string\":{\"query\":\"%s\"}}, \"minimum_should_match\" : 1}";
" ,\"filter\":{\"query_string\":{\"query\":\"{@}\"}}, \"minimum_should_match\" : 1}";
private static final String TEMPLATE_MATCH = "{\"query_string\": {\n" +
" \"fields\": [\"%s\"],\n" +
" \"query\": \"%s\"\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static ObjectNode queryStringPart(String field, String queryString) {
fieldValues.add(field);
query.set("fields", fieldValues);
}
query.put("query", queryString == null ? "%s" : queryString);
query.put("query", queryString == null ? "{@}" : queryString);

queryStringNode.set("query_string", query);

Expand Down

0 comments on commit 2ea70fe

Please sign in to comment.