Search in sources :

Example 16 with LuceneToJexlQueryParser

use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.

the class CompositeFunctionsTest method testTLDWithLuceneAndIdentifierToLiteralEQJexl.

@Test
public void testTLDWithLuceneAndIdentifierToLiteralEQJexl() throws Exception {
    tldEventQueryLogic.setParser(new LuceneToJexlQueryParser());
    Map<String, String> extraParameters = new HashMap<>();
    extraParameters.put("include.grouping.context", "true");
    if (log.isDebugEnabled()) {
        log.debug("testWithLucene");
    }
    // @formatter:off
    String[] queryStrings = { "UUID:ANDOLINI AND #JEXL(ETA == 12)" };
    @SuppressWarnings("unchecked") List<String>[] expectedLists = new List[] { Collections.singletonList("CORLEONE") };
    for (int i = 0; i < queryStrings.length; i++) {
        runTestQuery(expectedLists[i], queryStrings[i], format.parse("20091231"), format.parse("20150101"), extraParameters, tldEventQueryLogic);
    }
}
Also used : HashMap(java.util.HashMap) List(java.util.List) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Test(org.junit.Test)

Example 17 with LuceneToJexlQueryParser

use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.

the class CompositeFunctionsTest method testTLDWithLuceneAndIdentifierToLiteralLTJexl.

@Test
public void testTLDWithLuceneAndIdentifierToLiteralLTJexl() throws Exception {
    tldEventQueryLogic.setParser(new LuceneToJexlQueryParser());
    Map<String, String> extraParameters = new HashMap<>();
    extraParameters.put("include.grouping.context", "true");
    if (log.isDebugEnabled()) {
        log.debug("testWithLucene");
    }
    // @formatter:off
    String[] queryStrings = { // family name is ANDOLINI
    "UUID:ANDOLINI AND #JEXL(ETA < 15)" };
    @SuppressWarnings("unchecked") List<String>[] expectedLists = new List[] { Collections.singletonList("CORLEONE") };
    for (int i = 0; i < queryStrings.length; i++) {
        runTestQuery(expectedLists[i], queryStrings[i], format.parse("20091231"), format.parse("20150101"), extraParameters, tldEventQueryLogic);
    }
}
Also used : HashMap(java.util.HashMap) List(java.util.List) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Test(org.junit.Test)

Example 18 with LuceneToJexlQueryParser

use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.

the class CompositeFunctionsTest method testTLDWithLuceneAndIdentifierToIdentifierJexl.

@Test
public void testTLDWithLuceneAndIdentifierToIdentifierJexl() throws Exception {
    tldEventQueryLogic.setParser(new LuceneToJexlQueryParser());
    Map<String, String> extraParameters = new HashMap<>();
    extraParameters.put("include.grouping.context", "true");
    if (log.isDebugEnabled()) {
        log.debug("testWithLucene");
    }
    // @formatter:off
    String[] queryStrings = { "UUID:ANDOLINI AND #JEXL(ETA < MAGIC)" };
    @SuppressWarnings("unchecked") List<String>[] expectedLists = new List[] { Collections.singletonList("CORLEONE") };
    for (int i = 0; i < queryStrings.length; i++) {
        runTestQuery(expectedLists[i], queryStrings[i], format.parse("20091231"), format.parse("20150101"), extraParameters, tldEventQueryLogic);
    }
}
Also used : HashMap(java.util.HashMap) List(java.util.List) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Test(org.junit.Test)

Example 19 with LuceneToJexlQueryParser

use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.

the class TokensQueryTest method testLuceneField.

@Test
public void testLuceneField() throws Exception {
    String token = "nashua yuma";
    String query = GroupField.TOKENS.name() + ":\"" + token + "\"~4";
    String expect = GroupField.TOKENS.name() + EQ_OP + "'" + token + "'";
    this.logic.setParser(new LuceneToJexlQueryParser());
    runTest(query, expect);
}
Also used : LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Test(org.junit.Test)

Example 20 with LuceneToJexlQueryParser

use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.

the class GroupingTestWithModel method testGroupingUsingLuceneFunction.

@Test
public void testGroupingUsingLuceneFunction() throws Exception {
    Map<String, String> extraParameters = new HashMap<>();
    extraParameters.put("group.fields.batch.size", "6");
    Date startDate = format.parse("20091231");
    Date endDate = format.parse("20150101");
    String queryString = "(UUID:C* or UUID:S* ) and #GROUPBY('AG','GEN')";
    // @formatter:off
    Map<String, Integer> expectedMap = ImmutableMap.<String, Integer>builder().put("FEMALE-18", 2).put("MALE-30", 1).put("MALE-34", 1).put("MALE-16", 1).put("MALE-40", 2).put("MALE-20", 2).put("MALE-24", 1).put("MALE-22", 2).build();
    // @formatter:on
    logic.setParser(new LuceneToJexlQueryParser());
    for (RebuildingScannerTestHelper.TEARDOWN teardown : TEARDOWNS) {
        for (RebuildingScannerTestHelper.INTERRUPT interrupt : INTERRUPTS) {
            runTestQueryWithGrouping(expectedMap, queryString, startDate, endDate, extraParameters, teardown, interrupt);
        }
    }
    logic.setParser(new JexlControlledQueryParser());
}
Also used : HashMap(java.util.HashMap) RebuildingScannerTestHelper(datawave.query.RebuildingScannerTestHelper) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Date(java.util.Date) JexlControlledQueryParser(datawave.query.language.parser.jexl.JexlControlledQueryParser) Test(org.junit.Test)

Aggregations

LuceneToJexlQueryParser (datawave.query.language.parser.jexl.LuceneToJexlQueryParser)21 Test (org.junit.Test)17 HashMap (java.util.HashMap)11 List (java.util.List)7 Date (java.util.Date)5 RebuildingScannerTestHelper (datawave.query.RebuildingScannerTestHelper)3 JexlControlledQueryParser (datawave.query.language.parser.jexl.JexlControlledQueryParser)3 QueryNode (datawave.query.language.tree.QueryNode)3 Type (datawave.data.type.Type)2 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)2 Stopwatch (com.google.common.base.Stopwatch)1 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)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 EvaluationOnly (datawave.query.language.functions.jexl.EvaluationOnly)1 JexlQueryFunction (datawave.query.language.functions.jexl.JexlQueryFunction)1 QueryParser (datawave.query.language.parser.QueryParser)1