use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.
the class GroupingTest 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('AGE','$GENDER')";
// @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());
}
use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.
the class CompositeFunctionsTest method testWithLucene.
@Test
public void testWithLucene() throws Exception {
eventQueryLogic.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 starts with 'C'
"UUID:C*", // family name is SOPRANO
"UUID:SOPRANO", // family name starts with C or S
"UUID:C* OR UUID:S* ", // family has child CONSTANZIA
"(UUID:C* OR UUID:S*) AND #INCLUDE(NAM, 'CONSTANZIA') ", // family has child MICHAEL
"(UUID:C* OR UUID:S*) AND #INCLUDE(NAM, 'MICHAEL') ", // test LUCENE function to deliver jexl
"#JEXL(\"$UUID == 'CORLEONE' AND filter:getAllMatches(NAM,'SANTINO').size() == 1\")", "UUID:CORLEONE AND #JEXL(\"filter:getAllMatches(NAM,'SANTINO').size() == 1\")" };
@SuppressWarnings("unchecked") List<String>[] expectedLists = new List[] { // family name starts with 'C'
Arrays.asList("CAPONE", "CORLEONE"), // family name is SOPRANO
Collections.singletonList("SOPRANO"), // family name starts with C or S
Arrays.asList("SOPRANO", "CORLEONE", "CAPONE"), // family has child CONSTANZIA
Collections.singletonList("CORLEONE"), // family has child MICHAEL
Arrays.asList("CORLEONE", "CAPONE"), Collections.singletonList("CORLEONE"), Collections.singletonList("CORLEONE") };
for (int i = 0; i < queryStrings.length; i++) {
runTestQuery(expectedLists[i], queryStrings[i], format.parse("20091231"), format.parse("20150101"), extraParameters);
}
}
use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.
the class CompositeFunctionsTest method testMatchesAtLeastCountOfWithLucene.
@Test
public void testMatchesAtLeastCountOfWithLucene() throws Exception {
eventQueryLogic.setParser(new LuceneToJexlQueryParser());
Map<String, String> extraParameters = new HashMap<>();
extraParameters.put("include.grouping.context", "true");
if (log.isDebugEnabled()) {
log.debug("testMatchesAtLeastCountOfWithLucene");
}
String[] queryStrings = { "(UUID:C* OR UUID:S*) AND #MATCHES_AT_LEAST_COUNT_OF('3',NAM,'MICHAEL','VINCENT','FREDO','TONY')" };
@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);
}
}
use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.
the class CompositeFunctionsTest method testWithLuceneAndOptionsFunction.
@Test
public void testWithLuceneAndOptionsFunction() throws Exception {
eventQueryLogic.setParser(new LuceneToJexlQueryParser());
Map<String, String> extraParameters = new HashMap<>();
if (log.isDebugEnabled()) {
log.debug("testWithLucene");
}
// @formatter:off
String[] queryStrings = { // family name starts with 'C'
"UUID:C* AND #OPTIONS('include.grouping.context', 'true')", // family name is SOPRANO
"UUID:SOPRANO AND #OPTIONS('include.grouping.context', 'true')", // family name starts with C or S
"UUID:C* OR UUID:S* AND #OPTIONS('include.grouping.context', 'true')", // family has child CONSTANZIA
"(UUID:C* OR UUID:S*) AND #INCLUDE(NAM, 'CONSTANZIA') AND #OPTIONS('include.grouping.context', 'true')", // family has child MICHAEL
"(UUID:C* OR UUID:S*) AND #INCLUDE(NAM, 'MICHAEL') AND #OPTIONS('include.grouping.context', 'true')", // test LUCENE function to deliver jexl
"#JEXL(\"$UUID == 'CORLEONE' AND filter:getAllMatches(NAM,'SANTINO').size() == 1\") AND #OPTIONS('include.grouping.context', 'true')", "UUID:CORLEONE AND #JEXL(\"filter:getAllMatches(NAM,'SANTINO').size() == 1\") AND #OPTIONS('include.grouping.context', 'true')" };
@SuppressWarnings("unchecked") List<String>[] expectedLists = new List[] { // family name starts with 'C'
Arrays.asList("CAPONE", "CORLEONE"), // family name is SOPRANO
Collections.singletonList("SOPRANO"), // family name starts with C or S
Arrays.asList("SOPRANO", "CORLEONE", "CAPONE"), // family has child CONSTANZIA
Collections.singletonList("CORLEONE"), // family has child MICHAEL
Arrays.asList("CORLEONE", "CAPONE"), Collections.singletonList("CORLEONE"), Collections.singletonList("CORLEONE") };
// @formatter:on
for (int i = 0; i < queryStrings.length; i++) {
runTestQuery(expectedLists[i], queryStrings[i], format.parse("20091231"), format.parse("20150101"), extraParameters);
}
}
use of datawave.query.language.parser.jexl.LuceneToJexlQueryParser in project datawave by NationalSecurityAgency.
the class CompositeFunctionsTest method testDateDelta.
@Test
public void testDateDelta() throws Exception {
Map<String, String> extraParameters = new HashMap<>();
extraParameters.put("include.grouping.context", "true");
extraParameters.put("hit.list", "true");
if (log.isDebugEnabled()) {
log.debug("testDateDelta");
}
// @formatter:off
String[] queryStrings = { // 80+ years
"UUID =~ '^[CS].*' AND filter:getMaxTime(DEATH_DATE) - filter:getMinTime(BIRTH_DATE) > 2522880000000L", // 60+ years
"UUID =~ '^[CS].*' AND filter:getMaxTime(DEATH_DATE) - filter:getMinTime(BIRTH_DATE) > 1892160000000L", // 80+ years
"UUID =~ '^[CS].*' AND filter:timeFunction(DEATH_DATE,BIRTH_DATE,'-','>',2522880000000L)", "(UUID:C* OR UUID:S*) AND #TIME_FUNCTION(DEATH_DATE,BIRTH_DATE,'-','>','2522880000000L')" };
// timeFunction(Object time1, Object time2, String operatorString, String equalityString, long goal)
@SuppressWarnings("unchecked") List<String>[] expectedLists = new List[] { Collections.singletonList("CAPONE"), Arrays.asList("CORLEONE", "CAPONE"), Collections.singletonList("CAPONE"), Collections.singletonList("CAPONE") };
for (int i = 0; i < queryStrings.length; i++) {
if (i == 3) {
eventQueryLogic.setParser(new LuceneToJexlQueryParser());
}
runTestQuery(expectedLists[i], queryStrings[i], format.parse("20091231"), format.parse("20150101"), extraParameters);
}
}
Aggregations