Search in sources :

Example 21 with ShardQueryConfiguration

use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method oneToOneWithinCircleTest.

@Test
public void oneToOneWithinCircleTest() throws ParseException {
    String query = "geo:within_circle(ICE_CREAM, '-10_-10', '10') && TOPPINGS == 'HOT_FUDGE'";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(singleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("geo:within_circle(HOT_FUDGE_SUNDAE, '-10_-10', '10')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 22 with ShardQueryConfiguration

use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method oneToOneIntersectsTest.

@Test
public void oneToOneIntersectsTest() throws ParseException {
    String query = "geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && TOPPINGS == 'HOT_FUDGE'";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(singleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 23 with ShardQueryConfiguration

use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method reverseOneToOneAltFieldIntersectsTest.

@Test
public void reverseOneToOneAltFieldIntersectsTest() throws ParseException {
    String query = "FIXINGS == 'HOT_FUDGE' && geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(singleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 24 with ShardQueryConfiguration

use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method manyToOneIntersectsTest.

@Test
public void manyToOneIntersectsTest() throws ParseException {
    String query = "geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && (TOPPINGS == 'PEANUT' || TOPPINGS == 'PISTACHIO' || TOPPINGS == 'CASHEW')";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(manyToOneFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("geowave:intersects(NUT_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 25 with ShardQueryConfiguration

use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method oneToManyIntersectsDistributedUnchangedTest.

@Test
public void oneToManyIntersectsDistributedUnchangedTest() throws ParseException {
    String query = "FIELD == 'VALUE' && (TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA')";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(multipleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("FIELD == 'VALUE' && (TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)108 Test (org.junit.Test)75 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)48 HashSet (java.util.HashSet)42 Date (java.util.Date)38 GeometryType (datawave.data.type.GeometryType)17 MetadataHelper (datawave.query.util.MetadataHelper)17 HashMap (java.util.HashMap)16 CompositeFunctionsTest (datawave.query.CompositeFunctionsTest)13 Query (datawave.webservice.query.Query)10 Authorizations (org.apache.accumulo.core.security.Authorizations)10 Before (org.junit.Before)10 QueryImpl (datawave.webservice.query.QueryImpl)9 QueryParameters (datawave.webservice.query.QueryParameters)9 QueryParametersImpl (datawave.webservice.query.QueryParametersImpl)9 MultivaluedMapImpl (org.jboss.resteasy.specimpl.MultivaluedMapImpl)8 MockMetadataHelper (datawave.query.util.MockMetadataHelper)7 JexlNode (org.apache.commons.jexl2.parser.JexlNode)6 ExceededOrThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededOrThresholdMarkerJexlNode)5 ExceededValueThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode)5