Examples of TopDocs


Examples of org.apache.lucene.search.TopDocs

      DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
      Sort sort = new Sort(new SortField("foo", dsort));
     
      // Perform the search, using the term query, the serial chain filter, and the
      // distance sort
      TopDocs hits = searcher.search(customScore.createWeight(searcher),dq.getFilter(), 1000); //,sort);
      int results = hits.totalHits;
      ScoreDoc[] scoreDocs = hits.scoreDocs;
     
      // Get a list of distances
      Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    for (int i = 0; i < vals.length; i++) {
      if (vals[i].length() > 0)
        expecteds.add(vals[i]);
    }

    TopDocs td = searcher.search(q, 10);
    ScoreDoc[] sd = td.scoreDocs;
    for (int i = 0; i < sd.length; i++) {
      Document doc = searcher.doc(sd[i].doc);
      String id = doc.get("id");
      assertTrue(qString + "matched doc#" + id + " not expected", expecteds
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    chain = new ChainedFilter(new Filter[] {bobFilter});
    numHits = searcher.search(query, chain, 1000).totalHits;
    assertEquals(MAX / 2, numHits);
   
    chain = getChainedFilter(new Filter[] {bobFilter}, new int[] {ChainedFilter.AND});
    TopDocs hits = searcher.search(query, chain, 1000);
    numHits = hits.totalHits;
    assertEquals(MAX / 2, numHits);
    assertEquals("bob", searcher.doc(hits.scoreDocs[0].doc).get("owner"));
   
    chain = getChainedFilter(new Filter[] {bobFilter}, new int[] {ChainedFilter.ANDNOT});
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

  public void testAND() throws Exception {
    ChainedFilter chain = getChainedFilter(
      new Filter[] {dateFilter, bobFilter}, ChainedFilter.AND);

    TopDocs hits = searcher.search(query, chain, 1000);
    assertEquals("AND matches just bob", MAX / 2, hits.totalHits);
    assertEquals("bob", searcher.doc(hits.scoreDocs[0].doc).get("owner"));
  }
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

  public void testXOR() throws Exception {
    ChainedFilter chain = getChainedFilter(
      new Filter[]{dateFilter, bobFilter}, ChainedFilter.XOR);

    TopDocs hits = searcher.search(query, chain, 1000);
    assertEquals("XOR matches sue", MAX / 2, hits.totalHits);
    assertEquals("sue", searcher.doc(hits.scoreDocs[0].doc).get("owner"));
  }
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

  public void testANDNOT() throws Exception {
    ChainedFilter chain = getChainedFilter(
      new Filter[]{dateFilter, sueFilter},
        new int[] {ChainedFilter.AND, ChainedFilter.ANDNOT});

    TopDocs hits = searcher.search(query, chain, 1000);
    assertEquals("ANDNOT matches just bob",
        MAX / 2, hits.totalHits);
    assertEquals("bob", searcher.doc(hits.scoreDocs[0].doc).get("owner"));
   
    chain = getChainedFilter(
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    writer.commit();

    // try the search over the first doc
    DirectoryReader directoryReader = DirectoryReader.open(dir);
    IndexSearcher indexSearcher = newSearcher(directoryReader);
    TopDocs result = indexSearcher.search(new MatchAllDocsQuery(), 1);
    assertTrue(result.totalHits > 0);
    Document d = indexSearcher.doc(result.scoreDocs[0].doc);
    assertNotNull(d);
    assertNotNull(d.getField("title"));
    assertEquals(dummyTitle, d.getField("title").stringValue());
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    HashSet<Term> queryTerms = new HashSet<Term>();
    q.extractTerms(queryTerms);
    assertTrue("Should have variant smythe", queryTerms.contains(new Term("name", "smythe")));
    assertTrue("Should have variant smith", queryTerms.contains(new Term("name", "smith")));
    assertTrue("Should have variant smyth", queryTerms.contains(new Term("name", "smyth")));
    TopDocs topDocs = searcher.search(flt, 1);
    ScoreDoc[] sd = topDocs.scoreDocs;
    assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0));
    Document doc = searcher.doc(sd[0].doc);
    assertEquals("Should match most similar not most rare variant", "2", doc.get("id"));
  }
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    Query q = flt.rewrite(searcher.getIndexReader());
    HashSet<Term> queryTerms = new HashSet<Term>();
    q.extractTerms(queryTerms);
    assertTrue("Should have variant jonathan", queryTerms.contains(new Term("name", "jonathan")));
    assertTrue("Should have variant smith", queryTerms.contains(new Term("name", "smith")));
    TopDocs topDocs = searcher.search(flt, 1);
    ScoreDoc[] sd = topDocs.scoreDocs;
    assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0));
    Document doc = searcher.doc(sd[0].doc);
    assertEquals("Should match most similar when using 2 words", "2", doc.get("id"));
  }
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    Query q = flt.rewrite(searcher.getIndexReader());
    HashSet<Term> queryTerms = new HashSet<Term>();
    q.extractTerms(queryTerms);
    assertTrue("Should have variant jonathan", queryTerms.contains(new Term("name", "jonathan")));
    assertTrue("Should have variant smith", queryTerms.contains(new Term("name", "smith")));
    TopDocs topDocs = searcher.search(flt, 1);
    ScoreDoc[] sd = topDocs.scoreDocs;
    assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0));
    Document doc = searcher.doc(sd[0].doc);
    assertEquals("Should match most similar when using 2 words", "2", doc.get("id"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.