use of datawave.query.search.WildcardFieldedTerm in project datawave by NationalSecurityAgency.
the class LuceneUUIDQueryParser method parse.
@Override
public datawave.query.language.tree.QueryNode parse(String query) throws ParseException {
// replace open smart quote 147
query = query.replaceAll("\\u0093", "\"");
// replace close smart quote 148
query = query.replaceAll("\\u0094", "\"");
datawave.query.language.tree.QueryNode parsedQuery = null;
parsedQuery = super.parse(query);
if (!(parsedQuery instanceof SelectorNode)) {
throw new ParseException("Query: " + query + " not supported with the LuceneQueryUUIDParser");
}
SelectorNode selectorNode = (SelectorNode) parsedQuery;
FieldedTerm fieldedTerm = (FieldedTerm) selectorNode.getQuery();
String field = fieldedTerm.getField();
UUIDType uuidType = null;
for (UUIDType u : uuidTypes) {
if (u.getFieldName().equals(field)) {
uuidType = u;
break;
}
}
if (uuidType == null) {
throw new ParseException("Query: " + query + " not supported with the LuceneQueryUUIDParser");
}
if (fieldedTerm instanceof RangeFieldedTerm) {
throw new ParseException("Query: " + query + " not supported with the LuceneQueryUUIDParser");
}
if (fieldedTerm instanceof WildcardFieldedTerm) {
int firstWildcard = WildcardFieldedTerm.getFirstWildcardIndex(fieldedTerm.getSelector());
Integer wildcardAllowedAfter = uuidType.getAllowWildcardAfter();
if (wildcardAllowedAfter == null || firstWildcard < wildcardAllowedAfter) {
throw new ParseException("Query: " + query + " not supported with the LuceneQueryUUIDParser");
}
}
return parsedQuery;
}
use of datawave.query.search.WildcardFieldedTerm in project datawave by NationalSecurityAgency.
the class LuceneToJexlUUIDQueryParser method validUUIDSelectorNode.
private boolean validUUIDSelectorNode(QueryNode node) {
SelectorNode selectorNode = (SelectorNode) node;
FieldedTerm fieldedTerm = (FieldedTerm) selectorNode.getQuery();
String field = fieldedTerm.getField();
UUIDType uuidType = null;
for (UUIDType u : uuidTypes) {
if (u.getFieldName().equals(field)) {
uuidType = u;
break;
}
}
if (uuidType == null) {
return false;
}
if (fieldedTerm instanceof RangeFieldedTerm) {
return false;
}
if (fieldedTerm instanceof WildcardFieldedTerm) {
int firstWildcard = WildcardFieldedTerm.getFirstWildcardIndex(fieldedTerm.getSelector());
Integer wildcardAllowedAfter = uuidType.getAllowWildcardAfter();
if (wildcardAllowedAfter == null || firstWildcard < wildcardAllowedAfter) {
return false;
}
}
return true;
}
Aggregations