Skip to content

Commit

Permalink
Merge pull request #369 from tanvi029/mlayerdataset_upd
Browse files Browse the repository at this point in the history
mlayer-dataset query modified
  • Loading branch information
pranavrd authored Jun 19, 2024
2 parents 01fdb12 + 288905e commit be40642
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,18 @@ public MlayerService getMlayerDataset(

if (requestData.containsKey(TAGS) && !requestData.getJsonArray(TAGS).isEmpty()) {
JsonArray tagsArray = requestData.getJsonArray(TAGS);
JsonArray lowerTagsArray = new JsonArray();
String tagQueryString = "";

for (Object tagValue : tagsArray) {
if (tagValue instanceof String) {
lowerTagsArray.add(((String) tagValue).toLowerCase());
tagQueryString = tagQueryString.concat(tagValue + " OR ");
}
}

if (!lowerTagsArray.isEmpty()) {
query += ",{\"terms\":{\"tags.keyword\":" + lowerTagsArray.encode() + "}}";
if (!tagQueryString.isEmpty()) {
tagQueryString = "(" + tagQueryString.substring(0, tagQueryString.length() - 4) + ")";
query += ",{\"query_string\":{\"default_field\":\"tags\",\"query\":\""
+ tagQueryString + "\"}}";
}
}
if (requestData.containsKey(INSTANCE) && !requestData.getString(INSTANCE).isBlank()) {
Expand Down

0 comments on commit be40642

Please sign in to comment.