Examples of TopDocs


Examples of org.apache.lucene.search.TopDocs

    assertTrue(doc.score + " does not equal: " + 3, doc.score == 3);
  }

  public void testComplexNested() throws IOException {
    PayloadNearQuery query;
    TopDocs hits;

    // combine ordered and unordered spans with some nesting to make sure all payloads are counted

    SpanQuery q1 = newPhraseQuery("field", "nine hundred", true);
    SpanQuery q2 = newPhraseQuery("field", "ninety nine", true);
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    w.getReader().close();

    w.setMergedSegmentWarmer(new IndexWriter.IndexReaderWarmer() {
        public void warm(IndexReader r) throws IOException {
          final IndexSearcher s = new IndexSearcher(r);
          final TopDocs hits = s.search(new TermQuery(new Term("foo", "bar")), 10);
          assertEquals(20, hits.totalHits);
        }
      });
   
    Document doc = new Document();
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

  public void testQueryScorerHits() throws Exception {
    Analyzer analyzer = new SimpleAnalyzer();
    QueryParser qp = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
    query = qp.parse("\"very long\"");
    searcher = new IndexSearcher(ramDir, true);
    TopDocs hits = searcher.search(query, 10);
   
    QueryScorer scorer = new QueryScorer(query, FIELD_NAME);
    Highlighter highlighter = new Highlighter(scorer);

View Full Code Here

Examples of org.apache.lucene.search.TopDocs

        QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
        Query query = parser.parse("JF? or Kenned*");
        System.out.println("Searching with primitive query");
        // forget to set this and...
        // query=query.rewrite(reader);
        TopDocs hits = searcher.search(query, null, 1000);

        // create an instance of the highlighter with the tags used to surround
        // highlighted text
        // QueryHighlightExtractor highlighter = new
        // QueryHighlightExtractor(this,
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    Scorer scorer = new QueryTermScorer( query, searcher.getIndexReader(), "t_text1" );
    // This scorer doesn't use idf (patch version)
    //Scorer scorer = new QueryTermScorer( query, "t_text1" );
    Highlighter h = new Highlighter( scorer );

    TopDocs hits = searcher.search(query, null, 10);
    for( int i = 0; i < hits.totalHits; i++ ){
      Document doc = searcher.doc( hits.scoreDocs[i].doc );
      String result = h.getBestFragment( a, "t_text1", doc.get( "t_text1" ));
      System.out.println("result:" +  result);
      assertEquals("more <B>random</B> words for second field", result);
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    InstantiatedIndex ii = new InstantiatedIndex();

    IndexReader r = new InstantiatedIndexReader(ii);
    IndexSearcher s = new IndexSearcher(r);

    TopDocs td = s.search(new TermQuery(new Term("foo", "bar")), 1);

    assertEquals(0, td.totalHits);

    s.close();
    r.close();
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
    Sort sort = new Sort(new SortField("foo", dsort,false));

    // Perform the search, using the term query, the serial chain filter, and the
    // distance sort
    TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 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

    if (withSearch()) {
      res++;
      Query q = queryMaker.makeQuery();
      Sort sort = getSort();
      TopDocs hits;
      final int numHits = numHits();
      if (numHits > 0) {
        if (sort != null) {
          Weight w = q.weight(searcher);
          TopFieldCollector collector = TopFieldCollector.create(sort, numHits,
View Full Code Here

Examples of org.apache.lucene.search.TopDocs

    DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
    Sort sort = new Sort(new SortField("foo", dsort,false));

    // Perform the search, using the term query, the serial chain filter, and the
    // distance sort
    TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 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

      DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
      Sort sort = new Sort(new SortField("foo", dsort,false));
   
      // Perform the search, using the term query, the serial chain filter, and the
      // distance sort
      TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 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
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.