use of datawave.query.language.tree.QueryNode in project datawave by NationalSecurityAgency.
the class TestLuceneToJexlParser method test2.
@Test
public void test2() throws Exception {
LuceneToJexlQueryParser parser = getQueryParser();
QueryNode node = parser.parse("FIELD:SELECTOR AND #INCLUDE(F1, GB.*)");
Assert.assertEquals("FIELD == 'SELECTOR' && filter:includeRegex(F1, 'GB.*')", node.getOriginalQuery());
node = parser.parse("FIELD:SELECTOR AND #INCLUDE(F1, GB.{3})");
Assert.assertEquals("FIELD == 'SELECTOR' && filter:includeRegex(F1, 'GB.{3}')", node.getOriginalQuery());
node = parser.parse("FIELD:SELECTOR AND #INCLUDE(F1, GB\\.{3})");
Assert.assertEquals("FIELD == 'SELECTOR' && filter:includeRegex(F1, 'GB\\\\.{3}')", node.getOriginalQuery());
node = parser.parse("FIELD:SELECTOR AND #INCLUDE(F1, GB\\.{3\\,1})");
Assert.assertEquals("FIELD == 'SELECTOR' && filter:includeRegex(F1, 'GB\\\\.{3,1}')", node.getOriginalQuery());
node = parser.parse("FIELD:SOMETHING AND #EVALUATION_ONLY('#INCLUDE(F1, GB\\.{3\\,1})')");
Assert.assertEquals("FIELD == 'SOMETHING' && ((_Eval_ = true) && (filter:includeRegex(F1, 'GB\\\\.{3,1}')))", node.getOriginalQuery());
}
use of datawave.query.language.tree.QueryNode in project datawave by NationalSecurityAgency.
the class TestLuceneToJexlParser method evalOnlyTest.
@Test
public void evalOnlyTest() throws Exception {
LuceneToJexlQueryParser parser = getQueryParser();
QueryNode node = parser.parse("#EVALUATION_ONLY(\"(FIELD_1:FOO) OR (FIELD_2:BAR)\")");
Assert.assertEquals("((_Eval_ = true) && ((FIELD_1 == 'FOO') || (FIELD_2 == 'BAR')))", node.getOriginalQuery());
ASTJexlScript parsedNode = JexlASTHelper.parseJexlQuery(node.getOriginalQuery());
String parsedQuery = JexlStringBuildingVisitor.buildQuery(parsedNode);
Assert.assertEquals("((_Eval_ = true) && ((FIELD_1 == 'FOO') || (FIELD_2 == 'BAR')))", parsedQuery);
}
use of datawave.query.language.tree.QueryNode in project datawave by NationalSecurityAgency.
the class LuceneToJexlQueryParser method parse.
@Override
public QueryNode parse(String query) throws ParseException {
JexlNode parsedQuery = convertToJexlNode(query);
QueryNode node = new ServerHeadNode();
node.setOriginalQuery(parsedQuery.toString());
return node;
}
Aggregations