Search in sources :

Example 11 with QueryNode

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());
}
Also used : QueryNode(datawave.query.language.tree.QueryNode) Test(org.junit.Test)

Example 12 with QueryNode

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);
}
Also used : QueryNode(datawave.query.language.tree.QueryNode) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 13 with QueryNode

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;
}
Also used : QueryNode(datawave.query.language.tree.QueryNode) ServerHeadNode(datawave.query.language.tree.ServerHeadNode)

Aggregations

QueryNode (datawave.query.language.tree.QueryNode)13 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)5 Test (org.junit.Test)5 LuceneToJexlQueryParser (datawave.query.language.parser.jexl.LuceneToJexlQueryParser)3 Type (datawave.data.type.Type)2 ServerHeadNode (datawave.query.language.tree.ServerHeadNode)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 ASTEQNode (org.apache.commons.jexl2.parser.ASTEQNode)2 Stopwatch (com.google.common.base.Stopwatch)1 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 Lifecycle (datawave.microservice.querymetric.BaseQueryMetric.Lifecycle)1 ShardIndexQueryConfiguration (datawave.query.config.ShardIndexQueryConfiguration)1 QueryValues (datawave.query.discovery.FindLiteralsAndPatternsVisitor.QueryValues)1 EmptyUnfieldedTermExpansionException (datawave.query.exceptions.EmptyUnfieldedTermExpansionException)1 ShardIndexQueryTableStaticMethods (datawave.query.jexl.lookups.ShardIndexQueryTableStaticMethods)1 ParseException (datawave.query.language.parser.ParseException)1 QueryParser (datawave.query.language.parser.QueryParser)1