Examples of addFields()


Examples of org.apache.lucene.facet.index.FacetFields.addFields()

  /** Utility method to add a document and facets to an index/taxonomy. */
  private static void addFacets(FacetIndexingParams iParams, IndexWriter iw,
      TaxonomyWriter tw, String... strings) throws IOException {
    Document doc = new Document();
    FacetFields facetFields = new FacetFields(tw, iParams);
    facetFields.addFields(doc, Collections.singletonList(new CategoryPath(strings)));
    iw.addDocument(doc);
  }

  /** Clears the cache and sets its size to one. */
  private static void initCache() {
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

    TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
    FacetFields facetFields = new FacetFields(taxoWriter);
   
    for (String cat : CATEGORIES) {
      Document doc = new Document();
      facetFields.addFields(doc, Collections.singletonList(new CategoryPath(cat, '/')));
      indexWriter.addDocument(doc);
    }
   
    IOUtils.close(indexWriter, taxoWriter);
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

  }
 
  private Document newDocument(TaxonomyWriter taxoWriter, int id) throws IOException {
    Document doc = new Document();
    FacetFields facetFields = new FacetFields(taxoWriter);
    facetFields.addFields(doc, Collections.singleton(new CategoryPath("A", Integer.toString(id, 16))));
    return doc;
  }
 
  @Override
  @Before
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

      for (int j = i; j <= NUM_DOCS; j++) {
        int facetValue = asc? j: NUM_DOCS - j;
        categoryPaths.add(new CategoryPath("tag", Integer.toString(facetValue)));
      }
      FacetFields facetFields = new FacetFields(taxonomyWriter, fip);
      facetFields.addFields(doc, categoryPaths);
      writer.addDocument(doc);
    }   
    taxonomyWriter.close();
    writer.close();
 
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

    String[] categories = new String[] { "a/b", "c/d", "a/e", "a/d", "c/g", "c/z", "b/a", "1/2", "b/c" };

    FacetFields facetFields = new FacetFields(taxoWriter, iParams);
    for (String cat : categories) {
      Document doc = new Document();
      facetFields.addFields(doc, Collections.singletonList(new CategoryPath(cat, '/')));
      indexWriter.addDocument(doc);
    }

    // Commit Changes
    IOUtils.close(indexWriter, taxoWriter);
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

        String dim = DIMENSIONS[random.nextInt(DIMENSIONS.length)];
        // we should only increment the expected count by 1 per document
        docDimensions.add(dim);
        categories.add(new CategoryPath(dim, Integer.toString(i), Integer.toString(numCategories)));
      }
      facetFields.addFields(doc, categories);
      doc.add(new StringField("docid", Integer.toString(i), Store.YES));
      doc.add(new TextField("foo", "content" + i, Store.YES));
      indexWriter.addDocument(doc);

      // update expected count per dimension
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

      }
     
      if (random.nextDouble() < 0.2) { // add some documents that will be deleted
        doc = new Document();
        doc.add(new StringField("del", "key", Store.NO));
        facetFields.addFields(doc, Collections.singletonList(new CategoryPath("dummy")));
        indexWriter.addDocument(doc);
      }
    }
   
    indexWriter.commit();
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

public class IndexAndTaxonomyRevisionTest extends ReplicatorTestCase {
 
  private Document newDocument(TaxonomyWriter taxoWriter) throws IOException {
    Document doc = new Document();
    FacetFields ff = new FacetFields(taxoWriter);
    ff.addFields(doc, Collections.singleton(new CategoryPath("A")));
    return doc;
  }
 
  @Test
  public void testNoCommit() throws Exception {
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

      ArrayList<CategoryPath> categories = new ArrayList<CategoryPath>();
      for (int j = 0; j < numCategories; j++) {
        String dimension = dimensions[random.nextInt(dimensions.length)];
        categories.add(new CategoryPath(dimension, Integer.toString(i)));
      }
      facetFields.addFields(doc, categories);
      indexWriter.addDocument(doc);
    }
    IOUtils.close(indexWriter, taxoWriter);
   
    // test the multi iterator
View Full Code Here

Examples of org.apache.lucene.facet.index.FacetFields.addFields()

                  }
                }
                docPaths.add(new CategoryPath("field", path));
              }
              try {
                facetFields.addFields(doc, docPaths);
                w.addDocument(doc);
              } catch (IOException ioe) {
                throw new RuntimeException(ioe);
              }
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.