use of datawave.query.language.functions.jexl.JexlQueryFunction in project datawave by NationalSecurityAgency.
the class FunctionQueryNodeBuilder method build.
public JexlNode build(QueryNode queryNode) {
JexlNode returnNode = null;
int depth = 0;
QueryNode parent = queryNode;
while ((parent = parent.getParent()) != null) {
depth++;
}
if (queryNode instanceof FunctionQueryNode) {
FunctionQueryNode functionQueryNode = (FunctionQueryNode) queryNode;
String functionName = functionQueryNode.getFunction();
List<String> parameterList = functionQueryNode.getParameterList();
JexlQueryFunction referenceFunction = allowedFunctionMap.get(functionName.toUpperCase());
if (referenceFunction == null) {
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.FUNCTION_NOT_FOUND, MessageFormat.format("{0}", functionName));
throw new IllegalArgumentException(qe);
}
// if more than one term in quotes, use an AdjNode
JexlQueryFunction function = (JexlQueryFunction) referenceFunction.duplicate();
returnNode = new JexlFunctionNode(function, parameterList, depth, queryNode.getParent());
}
return returnNode;
}
use of datawave.query.language.functions.jexl.JexlQueryFunction in project datawave by NationalSecurityAgency.
the class LuceneQueryTest method testInit.
// ============================================
// implemented abstract methods
protected void testInit() {
this.auths = CitiesDataType.getTestAuths();
this.documentKey = CityField.EVENT_ID.name();
LuceneToJexlQueryParser parser = new LuceneToJexlQueryParser();
for (JexlQueryFunction queryFunction : parser.getAllowedFunctions()) {
if (queryFunction instanceof EvaluationOnly) {
((EvaluationOnly) queryFunction).setParser(parser);
break;
}
}
this.logic.setParser(parser);
}
use of datawave.query.language.functions.jexl.JexlQueryFunction in project datawave-query-metric-service by NationalSecurityAgency.
the class QueryMetricHandlerConfiguration method luceneToJexlQueryParser.
@Bean
@ConditionalOnMissingBean
public LuceneToJexlQueryParser luceneToJexlQueryParser() {
LuceneToJexlQueryParser luceneToJexlQueryParser = new LuceneToJexlQueryParser();
Set<String> skipTokenizedUnfieldedFields = new LinkedHashSet<>();
skipTokenizedUnfieldedFields.add("DOMETA");
luceneToJexlQueryParser.setSkipTokenizeUnfieldedFields(skipTokenizedUnfieldedFields);
Map<String, JexlQueryFunction> allowedFunctions = new LinkedHashMap<>();
for (JexlQueryFunction f : JexlTreeBuilder.DEFAULT_ALLOWED_FUNCTION_LIST) {
allowedFunctions.put(f.getClass().getCanonicalName(), f);
}
// configure EvaluationOnly with this parser
EvaluationOnly evaluationOnly = new EvaluationOnly();
evaluationOnly.setParser(luceneToJexlQueryParser);
allowedFunctions.put(EvaluationOnly.class.getCanonicalName(), evaluationOnly);
luceneToJexlQueryParser.setAllowedFunctions(new ArrayList<>(allowedFunctions.values()));
return luceneToJexlQueryParser;
}
Aggregations