Examples of doc()


Examples of org.apache.lucene.search.IndexSearcher.doc()

      System.out.println(q);
      TopDocs tds = searcher.search(q, 10);
      System.out.println("======size:"+tds.totalHits+"========");
      for(ScoreDoc sd : tds.scoreDocs) {
        System.out.println(sd.score);
        System.out.println(searcher.doc(sd.doc).get("txt"));
      }
    } catch (CorruptIndexException e) {
     
      e.printStackTrace();
    } catch (IOException e) {
View Full Code Here

Examples of org.apache.lucene.search.IndexSearcher.doc()

    QueryUtils.check(random, q,s);
    ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
    assertEquals("All docs should be matched!",N_DOCS,h.length);
    String prevID = "ID"+(N_DOCS+1); // greater than all ids of docs in this test
    for (int i=0; i<h.length; i++) {
      String resID = s.doc(h[i].doc).get(ID_FIELD);
      log(i+".   score="+h[i].score+"  -  "+resID);
      log(s.explain(q,h[i].doc));
      assertTrue("res id "+resID+" should be < prev res id "+prevID, resID.compareTo(prevID)<0);
      prevID = resID;
    }
View Full Code Here

Examples of org.apache.lucene.search.MultiSearcher.doc()

    // create an instance of the highlighter with the tags used to surround
    // highlighted text
    Highlighter highlighter = new Highlighter(this, new QueryTermScorer(query));

    for (int i = 0; i < hits.totalHits; i++) {
      String text = multiSearcher.doc(hits.scoreDocs[i].doc).get(FIELD_NAME);
      TokenStream tokenStream = analyzer.tokenStream(FIELD_NAME, new StringReader(text));
      String highlightedText = highlighter.getBestFragment(tokenStream, text);
      if (VERBOSE) System.out.println(highlightedText);
    }
    assertTrue("Failed to find correct number of highlights " + numHighlights + " found",
View Full Code Here

Examples of org.apache.lucene.search.ParallelMultiSearcher.doc()

      for(int i=query.offset; i<result.totalHits && i<(query.offset + query.limit); i++){
       
        Element el = new Element();
        el.setIndex(query.index);
                   
        Document d = multiSearcher.doc(result.scoreDocs[i].doc,fieldSelector);
        el.setKey(d.get(DOCUMENT_KEY));
       
        if(query.isSetPayload() && query.payload)
          el.setPayload(d.get(PAYLOAD_KEY));
     
View Full Code Here

Examples of org.apache.lucene.search.PwaMerger.doc()

        vecTermsAux.add(new PwaExtraTerm(new Term(fieldName,types[i]),reader))
      }     
      PwaMerger merger=new PwaMerger(vecTermsAux, false);
     
      while (merger.next()) {
        validDocs.set(merger.doc(), true);
      }     
    }
    System.out.println("Loading searched types to RAM at "+this.getClass().getSimpleName()+" class ended.");
  }
   
View Full Code Here

Examples of org.apache.lucene.search.Scorer.doc()

  public void testSpanNearScorerSkipTo1() throws Exception {
    SpanNearQuery q = makeQuery();
    Weight w = q.createWeight(searcher);
    Scorer s = w.scorer(searcher.getIndexReader());
    assertEquals(true, s.skipTo(1));
    assertEquals(1, s.doc());
  }
  /**
   * not a direct test of NearSpans, but a demonstration of how/when
   * this causes problems
   */
 
View Full Code Here

Examples of org.apache.lucene.search.Searchable.doc()

   * @throws IOException
   */
  protected Document doc(final String shardName, final int docId, final String[] fieldNames) throws IOException {
    final Searchable searchable = getSearcherByShard(shardName);
    if (fieldNames == null) {
      return searchable.doc(docId);
    } else {
      return searchable.doc(docId, new MapFieldSelector(fieldNames));
    }
  }

View Full Code Here

Examples of org.apache.lucene.search.Searcher.doc()

            }
            for (int i = 0, len = docs.scoreDocs.length;
                    i < limit && i + offset < docs.totalHits
                    && i + offset < len; i++) {
                ScoreDoc sd = docs.scoreDocs[i + offset];
                Document doc = searcher.doc(sd.doc);
                float score = sd.score;
                //## LUCENE3 end ##
                String q = doc.get(LUCENE_FIELD_QUERY);
                if (data) {
                    int idx = q.indexOf(" WHERE ");
View Full Code Here

Examples of org.apache.lucene.search.Searcher.doc()

    Highlighter highlighter = new Highlighter(formatter, new QueryScorer(
        query));
    highlighter.setTextFragmenter(new SimpleFragmenter(50));
    for (int i = 0; i < hits.scoreDocs.length; i++) {
      int docId = hits.scoreDocs[i].doc;
      Document hit = searcher.doc(docId);
      String text = hit.get(FIELD_NAME);
      int maxNumFragmentsRequired = 5;
      String fragmentSeparator = "...";
      TermPositionVector tpv = (TermPositionVector) reader
          .getTermFreqVector(docId, FIELD_NAME);
View Full Code Here

Examples of org.apache.lucene.search.Searcher.doc()

    Highlighter highlighter = new Highlighter(formatter, new QueryScorer(
        query));
    highlighter.setTextFragmenter(new SimpleFragmenter(50));
    for (int i = 0; i < hits.scoreDocs.length; i++) {
      int docId = hits.scoreDocs[i].doc;
      Document hit = searcher.doc(docId);
      String text = hit.get(FIELD_NAME);
      int maxNumFragmentsRequired = 5;
      String fragmentSeparator = "...";
      TermPositionVector tpv = (TermPositionVector) reader
          .getTermFreqVector(docId, FIELD_NAME);
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.