Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ public void exitFields(SearchParser.FieldsContext ctx) {
if (ctx.ANY() != null) {
fieldname = ctx.ANY().getText();
}
if (fieldname.contains("*")) {
if (this.knownFieldNames.isEmpty()) {
try {
for (PropertiesListInner property : ProductsController.productPropertiesList(this.connectionContext).getBody()) {
this.knownFieldNames.add(property.getProperty());
}
} catch (OpenSearchException | IOException e) {
log.error("Could not load the mapping(s) from opensearch; meaning 'wildcarding' will not work", e);
if (this.knownFieldNames.isEmpty()) {
try {
for (PropertiesListInner property : ProductsController.productPropertiesList(this.connectionContext).getBody()) {
this.knownFieldNames.add(property.getProperty());
}
} catch (OpenSearchException | IOException e) {
throw new IllegalStateException("Could not load the mapping(s) from opensearch; meaning 'q=' with field names will not work", e);
}
}
if (fieldname.contains("*")) {
String theKey = fieldname.replace(".", "\\.").replace("*", ".*");
Pattern regex = Pattern.compile(theKey);
for (String fn : this.knownFieldNames.stream()
Expand All @@ -94,7 +94,12 @@ public void exitFields(SearchParser.FieldsContext ctx) {
throw new ParseCancellationException("Wildcarding request '" + fieldname + "' cannot match any field names in the LDD using regular expression " + theKey);
}
} else {
this.fieldNames.add(SearchUtil.jsonPropertyToOpenProperty(fieldname));
String fn = SearchUtil.jsonPropertyToOpenProperty(fieldname);
if (this.fieldNames.contains(fn) ) {
this.fieldNames.add(fn);
} else {
throw new ParseCancellationException("The request '" + fieldname + "' does match any field names in the LDD.");
}
}
this.isAnyWildcard = ctx.ALL() == null && this.fieldNames.size() > 1;
}
Expand Down
Loading