private RawStructuredQueryDefinition allButCollectors() { StructuredQueryBuilder sqb = jobClient.newQueryManager().newStructuredQueryBuilder(); RawStructuredQueryDefinition allButCollectors = sqb.build( sqb.and( sqb.containerQuery(sqb.element("trace"), sqb.not(sqb.value(sqb.jsonProperty("label"), "collector"))))); return allButCollectors; }
@Test public void test105Searches() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); for (int i=0;i<105;i++) { for (QueryDefinition t : new QueryDefinition[] { qb.term("leaf3"), qb.build(qb.value(qb.element("leaf"), "leaf3")) }) { JacksonHandle results = queryMgr.search(t, new JacksonHandle()); assertNotNull(results); JsonNode jsonResults =results.get(); @SuppressWarnings("unused") String resultString = results.getMapper().writeValueAsString(jsonResults); // ignore. } } }
for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { xml = new StringInputStream(q); parser.parse(xml, handler); for (String q: new String[]{u.serialize(), qb.build(u).toString()}) { xml = new StringInputStream(q); parser.parse(xml, handler); for (String q: new String[]{v.serialize(), qb.build(v).toString()}) { xml = new StringInputStream(q); parser.parse(xml, handler); for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { xml = new StringInputStream(q); parser.parse(xml, handler); for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { xml = new StringInputStream(q); parser.parse(xml, handler); for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { xml = new StringInputStream(q); parser.parse(xml, handler); for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { xml = new StringInputStream(q); parser.parse(xml, handler); for (String q: new String[]{t.serialize(), qb.build(t).toString()}) {
@Test public void testStructuredSearch1() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); for (QueryDefinition t:new QueryDefinition[]{ qb.term("leaf3"), qb.build(qb.value(qb.element("leaf"), "leaf3")) }) { MatchDocumentSummary summary = queryMgr.findOne(t); assertNotNull(summary); GenericDocumentManager docMgr = Common.client.newDocumentManager(); assertNotNull("Document exists", docMgr.exists(summary.getUri())); } }
@Test public void testStructuredSearch() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); for (QueryDefinition t:new QueryDefinition[]{ qb.term("leaf3"), qb.build(qb.value(qb.element("leaf"), "leaf3")) }) { SearchHandle results = queryMgr.search(t, new SearchHandle()); assertNotNull(results); assertFalse(results.getMetrics().getTotalTime() == -1); MatchDocumentSummary[] summaries = results.getMatchResults(); assertNotNull(summaries); assertEquals("expected 1 result", 1, summaries.length); for (MatchDocumentSummary summary : summaries) { MatchLocation[] locations = summary.getMatchLocations(); assertEquals("expected 1 match location", 1, locations.length); for (MatchLocation location : locations) { assertNotNull(location.getAllSnippetText()); } } } }