コード例 #1
0
  @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()));
    }
  }
コード例 #2
0
  @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());
        }
      }
    }
  }