use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class CatalogMetricsTest method catalogFuzzyQueryMetric.
@Test
public void catalogFuzzyQueryMetric() throws Exception {
Filter fuzzyFilter = filterBuilder.attribute(Metacard.ANY_TEXT).like().fuzzyText("fuzzy");
QueryRequest query = new QueryRequestImpl(new QueryImpl(fuzzyFilter));
underTest.process(query);
assertThat(underTest.fuzzyQueries.getCount(), is(1L));
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class CatalogMetricsTest method catalogResultCountMetric.
@Test
public void catalogResultCountMetric() throws Exception {
QueryRequest query = new QueryRequestImpl(new QueryImpl(idFilter));
QueryResponse response = new QueryResponseImpl(query, new ArrayList(), 50);
underTest.process(response);
assertThat(underTest.resultCount.getCount(), is(1L));
assertThat(underTest.resultCount.getSnapshot().getMean(), is(50.0));
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class CatalogMetricsTest method catalogFederatedQueryMetricForLocalQueries.
@Test
public void catalogFederatedQueryMetricForLocalQueries() throws Exception {
QueryRequest query = new QueryRequestImpl(new QueryImpl(idFilter), Arrays.asList(""));
underTest.process(query);
query = new QueryRequestImpl(new QueryImpl(idFilter), Arrays.asList((String) null));
underTest.process(query);
System.setProperty(SystemInfo.SITE_NAME, "localSourceId");
query = new QueryRequestImpl(new QueryImpl(idFilter), Arrays.asList("localSourceId"));
underTest.process(query);
assertThat(underTest.federatedQueries.getCount(), is(0L));
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class SolrProviderTest method testQueryHasLuceneSpecialCharacters.
@Test
public void testQueryHasLuceneSpecialCharacters() throws Exception {
deleteAllIn(provider);
List<Metacard> list = Arrays.asList((Metacard) new MockMetacard(Library.getFlagstaffRecord()), new MockMetacard(Library.getTampaRecord()));
create(list);
// if + is escaped, this query will be an implicit OR otherwise both both terms would be
// required
Filter txtFilter = filterBuilder.attribute(Metacard.ANY_TEXT).like().text("+Flag?taff +" + TAMPA_QUERY_PHRASE);
SourceResponse response = provider.query(new QueryRequestImpl(new QueryImpl(txtFilter)));
assertEquals(1, response.getResults().size());
}
use of ddf.catalog.operation.impl.QueryRequestImpl in project ddf by codice.
the class SolrProviderTest method testXpathCompoundContextualQuery.
@Test
public void testXpathCompoundContextualQuery() throws Exception {
ConfigurationStore.getInstance().setDisableTextPath(false);
deleteAllIn(provider);
String nonexistentXpath = "/this/xpath[does/not/@ex:exist]";
MockMetacard tampa = new MockMetacard(Library.getTampaRecord());
tampa.setTitle("Tampa");
tampa.setLocation(TAMPA_AIRPORT_POINT_WKT);
MockMetacard flagstaff = new MockMetacard(Library.getFlagstaffRecord());
flagstaff.setLocation(FLAGSTAFF_AIRPORT_POINT_WKT);
create(Arrays.asList((Metacard) tampa, flagstaff));
/* XPath AND temporal AND spatial. */
Filter filter = filterBuilder.allOf(filterBuilder.xpath("/rss/channel[item/link]").exists(), filterBuilder.attribute(Metacard.MODIFIED).before().date(new DateTime().plus(1).toDate()), filterBuilder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(FLAGSTAFF_AIRPORT_POINT_WKT));
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("XPath AND temporal AND spatial", ONE_HIT, sourceResponse.getResults().size());
/* temporal AND (Bad XPath OR XPath) */
filter = filterBuilder.allOf(filterBuilder.attribute(Metacard.MODIFIED).before().date(new DateTime().plus(1).toDate()), filterBuilder.anyOf(filterBuilder.xpath(nonexistentXpath).exists(), filterBuilder.xpath("//channel/image/title").is().like().text(FLAGSTAFF_QUERY_PHRASE)));
sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("temporal AND (Bad XPath OR XPath)", ONE_HIT, sourceResponse.getResults().size());
/* Bad XPath OR (spatial AND XPath) */
filter = filterBuilder.anyOf(filterBuilder.xpath(nonexistentXpath).is().like().text("any phrase"), filterBuilder.allOf(filterBuilder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(TAMPA_AIRPORT_POINT_WKT), filterBuilder.xpath("/rss//item/enclosure/@url").exists()));
sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("Bad XPath OR (spatial AND XPath)", ONE_HIT, sourceResponse.getResults().size());
assertEquals("Tampa", sourceResponse.getResults().get(0).getMetacard().getTitle());
/* spatial AND (Bad XPath OR Bad XPath) */
filter = filterBuilder.allOf(filterBuilder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(FLAGSTAFF_AIRPORT_POINT_WKT), filterBuilder.anyOf(filterBuilder.xpath(nonexistentXpath).exists(), filterBuilder.xpath("//also/does/not[@exist]").is().like().text(FLAGSTAFF_QUERY_PHRASE)));
sourceResponse = provider.query(new QueryRequestImpl(new QueryImpl(filter)));
assertEquals("spatial AND (Bad XPath OR Bad XPath)", 0, sourceResponse.getResults().size());
}
Aggregations