Ejemplo n.º 1
0
  /**
   * {@inheritDoc}
   *
   * <p>Returns a {@link MultiScorer} if the passed <code>reader</code> is of type {@link
   * MultiIndexReader}.
   */
  public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
      throws IOException {
    if (reader instanceof MultiIndexReader) {
      MultiIndexReader mir = (MultiIndexReader) reader;
      IndexReader[] readers = mir.getIndexReaders();
      int[] starts = new int[readers.length + 1];
      int maxDoc = 0;
      for (int i = 0; i < readers.length; i++) {
        starts[i] = maxDoc;
        maxDoc += readers[i].maxDoc();
      }

      starts[readers.length] = maxDoc;
      Scorer[] scorers = new Scorer[readers.length];
      for (int i = 0; i < readers.length; i++) {
        scorers[i] = scorer(readers[i], scoreDocsInOrder, false);
      }

      return new MultiScorer(searcher.getSimilarity(), scorers, starts);
    } else {
      return createScorer(reader, scoreDocsInOrder, topScorer);
    }
  }
Ejemplo n.º 2
0
 public MatchNoneDocsWeight(Searcher searcher) {
   this.similarity = searcher.getSimilarity();
 }