Package org.apache.lucene.facet.index

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


  /** utility Create a dummy document with specified categories and content */
  protected final void indexDoc(FacetIndexingParams iParams, RandomIndexWriter iw,
      TaxonomyWriter tw, String content, List<CategoryPath> categories) throws IOException {
    Document d = new Document();
    FacetFields facetFields = new FacetFields(tw, iParams);
    facetFields.addFields(d, categories);
    d.add(new TextField("content", content, Field.Store.YES));
    iw.addDocument(d);
  }
 
  /** Build the "truth" with ALL the facets enumerating indexes content. */
 
View Full Code Here


   
    FacetFields facetFields = new FacetFields(tw, fip);
    for (int i = 0; i < 100; i++) {
      Document doc = new Document();
      CategoryPath cp = new CategoryPath("root",Integer.toString(i / 10), Integer.toString(i));
      facetFields.addFields(doc, Collections.singletonList(cp));
      w.addDocument(doc);
    }
    IOUtils.close(tw, w);
  }
View Full Code Here

      if ((l&3) == 0) {
        cp = new CategoryPath("dim", "a");
      } else {
        cp = new CategoryPath("dim", "b");
      }
      ff.addFields(doc, Collections.singletonList(cp));
      w.addDocument(doc);
    }

    final IndexReader r = w.getReader();
    w.close();
View Full Code Here

  /** 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

    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

  }
 
  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

      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

    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

        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

      }
     
      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

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.