Package org.apache.lucene.facet

Examples of org.apache.lucene.facet.FacetsConfig


      maxValue = Math.max(maxValue, v);
    }
    IndexReader r = w.getReader();

    IndexSearcher s = newSearcher(r);
    FacetsConfig config = new FacetsConfig();
   
    int numIters = atLeast(10);
    for(int iter=0;iter<numIters;iter++) {
      if (VERBOSE) {
        System.out.println("TEST: iter=" + iter);
View Full Code Here


      maxValue = Math.max(maxValue, v);
    }
    IndexReader r = w.getReader();

    IndexSearcher s = newSearcher(r);
    FacetsConfig config = new FacetsConfig();
   
    int numIters = atLeast(10);
    for(int iter=0;iter<numIters;iter++) {
      if (VERBOSE) {
        System.out.println("TEST: iter=" + iter);
View Full Code Here

      maxValue = Math.max(maxValue, v);
    }
    IndexReader r = w.getReader();

    IndexSearcher s = newSearcher(r);
    FacetsConfig config = new FacetsConfig();
   
    int numIters = atLeast(10);
    for(int iter=0;iter<numIters;iter++) {
      if (VERBOSE) {
        System.out.println("TEST: iter=" + iter);
View Full Code Here

        public String description() {
          throw new UnsupportedOperationException();
        }
      };

    FacetsConfig config = new FacetsConfig();
   
    FacetsCollector fc = new FacetsCollector();

    IndexReader r = writer.getReader();
    IndexSearcher s = newSearcher(r);
View Full Code Here

      termExpectedCounts.put(CP_D, termExpectedCounts.get(CP_D) + 1);
    }
  }

  private static FacetsConfig getConfig() {
    FacetsConfig config = new FacetsConfig();
    config.setMultiValued("A", true);
    config.setMultiValued("B", true);
    config.setRequireDimCount("B", true);
    config.setHierarchical("D", true);
    return config;
  }
View Full Code Here

 
  private static void indexDocsWithFacetsNoTerms(IndexWriter indexWriter, TaxonomyWriter taxoWriter,
                                                 Map<String,Integer> expectedCounts) throws IOException {
    Random random = random();
    int numDocs = atLeast(random, 2);
    FacetsConfig config = getConfig();
    for (int i = 0; i < numDocs; i++) {
      Document doc = new Document();
      addFacets(doc, config, false);
      indexWriter.addDocument(config.build(taxoWriter, doc));
    }
    indexWriter.commit(); // flush a segment
  }
View Full Code Here

 
  private static void indexDocsWithFacetsAndTerms(IndexWriter indexWriter, TaxonomyWriter taxoWriter,
                                                  Map<String,Integer> expectedCounts) throws IOException {
    Random random = random();
    int numDocs = atLeast(random, 2);
    FacetsConfig config = getConfig();
    for (int i = 0; i < numDocs; i++) {
      Document doc = new Document();
      addFacets(doc, config, true);
      addField(doc);
      indexWriter.addDocument(config.build(taxoWriter, doc));
    }
    indexWriter.commit(); // flush a segment
  }
View Full Code Here

 
  private static void indexDocsWithFacetsAndSomeTerms(IndexWriter indexWriter, TaxonomyWriter taxoWriter,
                                                      Map<String,Integer> expectedCounts) throws IOException {
    Random random = random();
    int numDocs = atLeast(random, 2);
    FacetsConfig config = getConfig();
    for (int i = 0; i < numDocs; i++) {
      Document doc = new Document();
      boolean hasContent = random.nextBoolean();
      if (hasContent) {
        addField(doc);
      }
      addFacets(doc, config, hasContent);
      indexWriter.addDocument(config.build(taxoWriter, doc));
    }
    indexWriter.commit(); // flush a segment
  }
View Full Code Here

    // preparations - index, taxonomy, content
   
    TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);

    // Cannot mix ints & floats in the same indexed field:
    config = new FacetsConfig();
    config.setIndexFieldName("int", "$facets.int");
    config.setMultiValued("int", true);
    config.setIndexFieldName("float", "$facets.float");
    config.setMultiValued("float", true);
View Full Code Here

  public void testMixedTypesInSameIndexField() throws Exception {
    Directory dir = newDirectory();
    Directory taxoDir = newDirectory();
   
    TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
    FacetsConfig config = new FacetsConfig();
    RandomIndexWriter writer = new RandomIndexWriter(random(), dir);

    Document doc = new Document();
    doc.add(new IntAssociationFacetField(14, "a", "x"));
    doc.add(new FloatAssociationFacetField(55.0f, "b", "y"));
    try {
      writer.addDocument(config.build(taxoWriter, doc));
      fail("did not hit expected exception");
    } catch (IllegalArgumentException exc) {
      // expected
    }
    IOUtils.close(writer, taxoWriter, dir, taxoDir);
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.FacetsConfig

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.