Search in sources :

Example 96 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class DatawaveSelectorExtractorTest method extractSelectorsJEXLQuery3.

@Test
public void extractSelectorsJEXLQuery3() {
    DatawaveSelectorExtractor extractor = new DatawaveSelectorExtractor();
    QueryImpl q = new QueryImpl();
    q.setQuery("FIELD1 == 'selector1' || _ANY_FIELD_ == 'selector2' || (_ANY_FIELD_ == 'selector3' && _ANY_FIELD_ == 'selector4')");
    List<String> selectorList = extractor.extractSelectors(q);
    List<String> expected = Lists.newArrayList("selector1", "selector2", "selector3", "selector4");
    Assert.assertEquals(expected, selectorList);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Test(org.junit.Test)

Example 97 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class SplitSelectorExtractorTest method extractSelectorsLuceneQuery1.

@Test
public void extractSelectorsLuceneQuery1() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    QueryImpl q = new QueryImpl();
    q.setQuery("selector1");
    List<String> selectorList = extractor.extractSelectors(q);
    List<String> expected = Lists.newArrayList("selector1");
    Assert.assertEquals(expected, selectorList);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Test(org.junit.Test)

Example 98 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class SplitSelectorExtractorTest method extractSelectorsLuceneQuery2.

@Test
public void extractSelectorsLuceneQuery2() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    extractor.setSeparatorCharacter(";");
    QueryImpl q = new QueryImpl();
    q.setQuery("selector1;selector2;selector3");
    List<String> selectorList = extractor.extractSelectors(q);
    List<String> expected = Lists.newArrayList("selector1", "selector2", "selector3");
    Assert.assertEquals(expected, selectorList);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Test(org.junit.Test)

Example 99 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class ExceededOrThresholdMarkerJexlNodeTest method getQueryRangesIterator.

private Iterator getQueryRangesIterator(String queryString, ShardQueryLogic logic) throws Exception {
    MultivaluedMap<String, String> params = new MultivaluedMapImpl<>();
    params.putSingle(QUERY_LOGIC_NAME, "EventQuery");
    params.putSingle(QUERY_STRING, queryString);
    params.putSingle(QUERY_NAME, "geoQuery");
    params.putSingle(QUERY_PERSISTENCE, "PERSISTENT");
    params.putSingle(QUERY_AUTHORIZATIONS, AUTHS);
    params.putSingle(QUERY_EXPIRATION, "20200101 000000.000");
    params.putSingle(QUERY_BEGIN, BEGIN_DATE);
    params.putSingle(QUERY_END, END_DATE);
    QueryParameters queryParams = new QueryParametersImpl();
    queryParams.validate(params);
    Set<Authorizations> auths = new HashSet<>();
    auths.add(new Authorizations(AUTHS));
    Query query = new QueryImpl();
    query.initialize(USER, Arrays.asList(USER_DN), null, queryParams, null);
    ShardQueryConfiguration config = ShardQueryConfiguration.create(logic, query);
    logic.initialize(config, instance.getConnector("root", PASSWORD), query, auths);
    logic.setupQuery(config);
    return Iterators.transform(config.getQueries(), queryData -> {
        try {
            return JexlStringBuildingVisitor.buildQuery(PushdownLargeFieldedListsVisitor.pushdown(config, JexlASTHelper.parseJexlQuery(queryData.getQuery()), null, null));
        } catch (ParseException e) {
            return null;
        }
    });
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) MultivaluedMapImpl(org.jboss.resteasy.specimpl.MultivaluedMapImpl) QueryParameters(datawave.webservice.query.QueryParameters) ParseException(org.apache.commons.jexl2.parser.ParseException) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) HashSet(java.util.HashSet)

Example 100 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class ContentFunctionQueryTest method getResultsIterator.

private Iterator getResultsIterator(String queryString, ShardQueryLogic logic, MultiValueMap<String, String> optionalParams) throws Exception {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.set(QUERY_STRING, queryString);
    params.set(QUERY_NAME, "contentQuery");
    params.set(QUERY_LOGIC_NAME, "EventQueryLogic");
    params.set(QUERY_PERSISTENCE, "PERSISTENT");
    params.set(QUERY_AUTHORIZATIONS, AUTHS);
    params.set(QUERY_EXPIRATION, "20200101 000000.000");
    params.set(QUERY_BEGIN, BEGIN_DATE);
    params.set(QUERY_END, END_DATE);
    QueryParameters queryParams = new QueryParametersImpl();
    queryParams.validate(params);
    Set<Authorizations> auths = new HashSet<>();
    auths.add(new Authorizations(AUTHS));
    Query query = new QueryImpl();
    query.initialize(USER, Arrays.asList(USER_DN), null, queryParams, optionalParams);
    ShardQueryConfiguration config = ShardQueryConfiguration.create(logic, query);
    logic.initialize(config, instance.getConnector("root", PASSWORD), query, auths);
    logic.setupQuery(config);
    return logic.getTransformIterator(query);
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) QueryParameters(datawave.webservice.query.QueryParameters) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) HashSet(java.util.HashSet)

Aggregations

QueryImpl (datawave.webservice.query.QueryImpl)131 Test (org.junit.Test)96 ArrayList (java.util.ArrayList)54 Query (datawave.webservice.query.Query)40 HashSet (java.util.HashSet)27 BaseQueryLogic (datawave.webservice.query.logic.BaseQueryLogic)18 GenericQueryConfiguration (datawave.webservice.query.configuration.GenericQueryConfiguration)16 Date (java.util.Date)16 QueryParametersImpl (datawave.webservice.query.QueryParametersImpl)14 MultivaluedMapImpl (org.jboss.resteasy.specimpl.MultivaluedMapImpl)13 QueryMetricFactoryImpl (datawave.microservice.querymetric.QueryMetricFactoryImpl)12 QueryParameters (datawave.webservice.query.QueryParameters)12 Value (org.apache.accumulo.core.data.Value)10 Document (datawave.query.attributes.Document)9 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)9 EdgeQueryFunctionalTest (datawave.query.tables.edge.EdgeQueryFunctionalTest)9 QueryLogic (datawave.webservice.query.logic.QueryLogic)9 HashMap (java.util.HashMap)9 Key (org.apache.accumulo.core.data.Key)9 Authorizations (org.apache.accumulo.core.security.Authorizations)9