Examples of ScoredDocIDsIterator


Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

      private int size = -1;
      public DocIdSet getDocIDs() { return docIdSet; }

      public ScoredDocIDsIterator iterator() throws IOException {
        final DocIdSetIterator docIterator = docIdSet.iterator();
        return new ScoredDocIDsIterator() {
          public boolean next() {
            try {
              return docIterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
            } catch (IOException e) {
              throw new RuntimeException(e);
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

    }

    public ScoredDocIDsIterator iterator() {
      try {
        final DocIdSetIterator iter = getDocIDs().iterator();
        return new ScoredDocIDsIterator() {
          public boolean next() {
            try {
              return iter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
            } catch (IOException e) {
              // cannot happen
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

    }

    public ScoredDocIDsIterator iterator() {
      try {
        final DocIdSetIterator iter = getDocIDs().iterator();
        return new ScoredDocIDsIterator() {
          public boolean next() {
            try {
              return iter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
            } catch (IOException e) {
              // cannot happen
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

    Directory dir = newDirectory();
    IndexReader reader = createReaderWithNDocs(random, maxDoc, dir);
    try {
      ScoredDocIDs all = ScoredDocIdsUtils.createAllDocsScoredDocIDs(reader);
      assertEquals("invalid size", maxDoc, all.size());
      ScoredDocIDsIterator iter = all.iterator();
      int doc = 0;
      while (iter.next()) {
        assertEquals("invalid doc ID: " + iter.getDocID(), doc++, iter.getDocID());
        assertEquals("invalid score: " + iter.getScore(), ScoredDocIDsIterator.DEFAULT_SCORE, iter.getScore(), 0.0f);
      }
      assertEquals("invalid maxDoc: " + doc, maxDoc, doc);
     
      DocIdSet docIDs = all.getDocIDs();
      assertTrue("should be cacheable", docIDs.isCacheable());
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

   
    Directory dir = newDirectory();
    IndexReader reader = createReaderWithNDocs(random, N_DOCS, docFactory, dir);
    try {
      ScoredDocIDs allDocs = ScoredDocIdsUtils.createAllDocsScoredDocIDs(reader);
      ScoredDocIDsIterator it = allDocs.iterator();
      int numIteratedDocs = 0;
      while (it.next()) {
        numIteratedDocs++;
        int docNum = it.getDocID();
        assertNull(
            "Deleted docs must not appear in the allDocsScoredDocIds set: " + docNum,
            reader.document(docNum).getFieldable("del"));
      }

      assertEquals("Wrong number of (live) documents", allDocs.size(), numIteratedDocs);

      // Get all 'alpha' documents
      ScoredDocIdCollector collector = ScoredDocIdCollector.create(reader.maxDoc(), false);
      Query q = new TermQuery(new Term(DocumentFactory.field, DocumentFactory.alphaTxt));
      IndexSearcher searcher = newSearcher(reader);
      searcher.search(q, collector);
      searcher.close();

      ScoredDocIDs scoredDocIds = collector.getScoredDocIDs();
      OpenBitSet resultSet = new OpenBitSetDISI(scoredDocIds.getDocIDs().iterator(), reader.maxDoc());
     
      // Getting the complement set of the query result
      ScoredDocIDs complementSet = ScoredDocIdsUtils.getComplementSet(scoredDocIds, reader);

      assertEquals("Number of documents in complement set mismatch",
          reader.numDocs() - scoredDocIds.size(), complementSet.size());

      // now make sure the documents in the complement set are not deleted
      // and not in the original result set
      ScoredDocIDsIterator compIterator = complementSet.iterator();
      while (compIterator.next()) {
        int docNum = compIterator.getDocID();
        assertFalse(
            "Complement-Set must not contain deleted documents (doc="+docNum+")",
            reader.isDeleted(docNum));
        assertNull(
            "Complement-Set must not contain docs from the original set (doc="+ docNum+")",
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

    searcher.search(q, dCollector);

    // verify by doc scores at the level of doc-id-iterator
    ScoredDocIDs scoredDocIDs = dCollector.getScoredDocIDs();
    assertEquals("Wrong number of matching documents!", 2, scoredDocIDs.size());
    ScoredDocIDsIterator docItr = scoredDocIDs.iterator();
    while (docItr.next()) {
      assertEquals("Wrong score for doc " + docItr.getDocID(), constScore,
          docItr.getScore(), Double.MIN_VALUE);
    }

    // verify by facet values
    List<FacetResult> countRes = findFacets(scoredDocIDs, getFacetedSearchParams());
    List<FacetResult> scoreRes = findFacets(scoredDocIDs, sumScoreSearchParams());
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

    for (int i = 0; i < docs.length; i++) {
      sdic.collect(docs[i]);
    }

    assertEquals("expected 3 documents but got " + sdic.getScoredDocIDs().size(), 3, sdic.getScoredDocIDs().size());
    ScoredDocIDsIterator iter = sdic.getScoredDocIDs().iterator();
    Arrays.sort(docs);
    for (int i = 0; iter.next(); i++) {
      assertEquals("expected doc " + docs[i], docs[i], iter.getDocID());
    }
  }
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

    // sort so that we can scan docs in order
    final int[] docids = sampleSet;
    Arrays.sort(docids);
    final float[] scores = new float[docids.length];
    // fetch scores and compute size
    ScoredDocIDsIterator it = allDocIds.iterator();
    int n = 0;
    while (it.next() && n < docids.length) {
      int doc = it.getDocID();
      if (doc == docids[n]) {
        scores[n] = it.getScore();
        ++n;
      }
    }
    final int size = n;

    return new ScoredDocIDs() {

      @Override
      public DocIdSet getDocIDs() {
        return new DocIdSet() {

          @Override
          public boolean isCacheable() { return true; }

          @Override
          public DocIdSetIterator iterator() {
            return new DocIdSetIterator() {

              private int next = -1;

              @Override
              public int advance(int target) {
                while (next < size && docids[next++] < target) {
                }
                return next == size ? NO_MORE_DOCS : docids[next];
              }

              @Override
              public int docID() {
                return docids[next];
              }

              @Override
              public int nextDoc() {
                if (++next >= size) {
                  return NO_MORE_DOCS;
                }
                return docids[next];
              }

            };
          }
        };
      }

      @Override
      public ScoredDocIDsIterator iterator() {
        return new ScoredDocIDsIterator() {

          int next = -1;

          @Override
          public boolean next() { return ++next < size; }
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

      public DocIdSet getDocIDs() { return docIdSet; }

      @Override
      public ScoredDocIDsIterator iterator() throws IOException {
        final DocIdSetIterator docIterator = docIdSet.iterator();
        return new ScoredDocIDsIterator() {
          @Override
          public boolean next() {
            try {
              return docIterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
            } catch (IOException e) {
View Full Code Here

Examples of org.apache.lucene.facet.search.ScoredDocIDsIterator

    @Override
    public ScoredDocIDsIterator iterator() {
      try {
        final DocIdSetIterator iter = getDocIDs().iterator();
        return new ScoredDocIDsIterator() {
          @Override
          public boolean next() {
            try {
              return iter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
            } catch (IOException e) {
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.