Package org.apache.lucene.facet.search

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


   */
  public CategoryListIterator createCategoryListIterator(IndexReader reader,
      int partition) throws IOException {
    String categoryListTermStr = PartitionsUtils.partitionName(this, partition);
    Term payloadTerm = term.createTerm(categoryListTermStr);
    return new PayloadIntDecodingIterator(reader, payloadTerm,
        createEncoder().createMatchingDecoder());
  }
View Full Code Here


   *            the field containing the relevant associations list term
   */
  public AssociationsPayloadIterator(IndexReader reader, String field)
      throws IOException {
    // Initialize the payloadDecodingIterator
    associationPayloadIter = new PayloadIntDecodingIterator(
        reader,
        // TODO (Facet): should consolidate with AssociationListTokenizer which
        // uses AssociationEnhancement.getCatTermText()
        new Term(field, AssociationEnhancement.CATEGORY_LIST_TERM_TEXT),
        new SimpleIntDecoder());
View Full Code Here

      writer.addDocument(doc);
    }
    IndexReader reader = writer.getReader();
    writer.close();

    CategoryListIterator cli = new PayloadIntDecodingIterator(reader, new Term(
        "f","1"), dts.encoder.createMatchingDecoder());
    cli.init();
    int totalCategories = 0;
    for (int i = 0; i < data.length; i++) {
      Set<Integer> values = new HashSet<Integer>();
      for (int j = 0; j < data[i].length; j++) {
        values.add(data[i][j]);
      }
      cli.skipTo(i);
      long cat;
      while ((cat = cli.nextCategory()) < Integer.MAX_VALUE) {
        assertTrue("expected category not found: " + cat, values.contains((int) cat));
        totalCategories ++;
      }
    }
    assertEquals("Missing categories!",10,totalCategories);
View Full Code Here

    }

    IndexReader reader = writer.getReader();
    writer.close();

    CategoryListIterator cli = new PayloadIntDecodingIterator(reader, new Term(
        "f","1"), dts.encoder.createMatchingDecoder());
    cli.init();
    int totalCats = 0;
    for (int i = 0; i < data.length; i++) {
      // doc no. i
      Set<Integer> values = new HashSet<Integer>();
      for (int j = 0; j < data[i].length; j++) {
        values.add(data[i][j]);
      }
      boolean hasDoc = cli.skipTo(i);
      if (hasDoc) {
        assertTrue("Document "+i+" must not have a payload!", i==0 || i==2 );
        long cat;
        while ((cat = cli.nextCategory()) < Integer.MAX_VALUE) {
          assertTrue("expected category not found: " + cat, values.contains((int) cat));
          ++totalCats;
        }
      } else {
        assertFalse("Document "+i+" must have a payload!", i==0 || i==2 );
      }

    }
    assertEquals("Wrong number of total categories!", 4, totalCats);

    // Ok.. went through the first 4 docs, now lets try the 6th doc (docid 5)
    assertFalse("Doc #6 (docid=5) should not have a payload!",cli.skipTo(5));
    reader.close();
    dir.close();
  }
View Full Code Here

      writer.addDocument(doc);
    }
    IndexReader reader = writer.getReader();
    writer.close();

    CategoryListIterator cli = new PayloadIntDecodingIterator(reader, new Term(
        "f","1"), dts.encoder.createMatchingDecoder());
    cli.init();
    int totalCategories = 0;
    for (int i = 0; i < data.length; i++) {
      Set<Integer> values = new HashSet<Integer>();
      for (int j = 0; j < data[i].length; j++) {
        values.add(data[i][j]);
      }
      cli.skipTo(i);
      long cat;
      while ((cat = cli.nextCategory()) < Integer.MAX_VALUE) {
        assertTrue("expected category not found: " + cat, values.contains((int) cat));
        totalCategories ++;
      }
    }
    assertEquals("Missing categories!",10,totalCategories);
View Full Code Here

    }

    IndexReader reader = writer.getReader();
    writer.close();

    CategoryListIterator cli = new PayloadIntDecodingIterator(reader, new Term(
        "f","1"), dts.encoder.createMatchingDecoder());
    assertTrue("Failed to initialize payload iterator", cli.init());
    int totalCats = 0;
    for (int i = 0; i < data.length; i++) {
      // doc no. i
      Set<Integer> values = new HashSet<Integer>();
      for (int j = 0; j < data[i].length; j++) {
        values.add(data[i][j]);
      }
      boolean hasDoc = cli.skipTo(i);
      if (hasDoc) {
        assertTrue("Document " + i + " must not have a payload!", i == 0);
        long cat;
        while ((cat = cli.nextCategory()) < Integer.MAX_VALUE) {
          assertTrue("expected category not found: " + cat, values.contains((int) cat));
          ++totalCats;
        }
      } else {
        assertFalse("Document " + i + " must have a payload!", i == 0);
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.search.PayloadIntDecodingIterator

Copyright © 2018 www.massapicom. 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.