Package org.apache.lucene.facet.enhancements

Examples of org.apache.lucene.facet.enhancements.EnhancementsDocumentBuilder


    TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir);

    // a category document builder will add the categories to a document
    // once build() is called
    Document doc = new Document();
    indexWriter.addDocument(new EnhancementsDocumentBuilder(taxo,
        indexingParams).setCategoryPaths(categoryPaths).build(doc));

    IndexReader indexReader = indexWriter.getReader();
    indexWriter.close();
View Full Code Here


    TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir);

    // a category document builder will add the categories to a document
    // once build() is called
    Document doc = new Document();
    indexWriter.addDocument(new EnhancementsDocumentBuilder(taxo,
        indexingParams).setCategoryPaths(categoryPaths).build(doc));

    IndexReader indexReader = indexWriter.getReader();
    indexWriter.close();
View Full Code Here

      }

      // we do not alter indexing parameters!
      // a category document builder will add the categories to a document
      // once build() is called
      CategoryDocumentBuilder categoryDocBuilder = new EnhancementsDocumentBuilder(
          taxo, AssociationUtils.assocIndexingParams);
      categoryDocBuilder.setCategories(categoryContainer);

      // create a plain Lucene document and add some regular Lucene fields
      // to it
      Document doc = new Document();
      doc.add(new Field(SimpleUtils.TITLE, SimpleUtils.docTitles[docNum],
          Store.YES, Index.ANALYZED));
      doc.add(new Field(SimpleUtils.TEXT, SimpleUtils.docTexts[docNum],
          Store.NO, Index.ANALYZED));

      // invoke the category document builder for adding categories to the
      // document and,
      // as required, to the taxonomy index
      categoryDocBuilder.build(doc);

      // finally add the document to the index
      iw.addDocument(doc);

      nDocsAdded++;
View Full Code Here

    RandomIndexWriter w = new RandomIndexWriter(random, iDir,
        newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.KEYWORD, false)));
    LuceneTaxonomyWriter taxoW = new LuceneTaxonomyWriter(tDir);
   
    CategoryContainer cc = new CategoryContainer();
    EnhancementsDocumentBuilder builder = new EnhancementsDocumentBuilder(taxoW, iParams);
    for (int i = 1; i <= NUM_CATEGORIES; i++) {
      CategoryAttributeImpl ca = new CategoryAttributeImpl(new CategoryPath(Integer.toString(i)));
      ca.addProperty(new CustomProperty(i));
     
      cc.addCategory(ca);
    }
    builder.setCategories(cc);
    w.addDocument(builder.build(new Document()));
    taxoW.close();
    IndexReader reader = w.getReader();
    w.close();
   
    LuceneTaxonomyReader taxo = new LuceneTaxonomyReader(tDir);
View Full Code Here

    RandomIndexWriter writer = new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT,
        new MockAnalyzer(random, MockTokenizer.KEYWORD, false)));
   
    TaxonomyWriter taxoWriter = new LuceneTaxonomyWriter(taxoDir);
   
    EnhancementsDocumentBuilder builder = new EnhancementsDocumentBuilder(
        taxoWriter, new DefaultEnhancementsIndexingParams(
            new AssociationEnhancement()));
   
    // index documents, 50% have only 'b' and all have 'a'
    for (int i = 0; i < 100; i++) {
      Document doc = new Document();
      CategoryContainer container = new CategoryContainer();
      container.addCategory(aint, new AssociationIntProperty(2));
      container.addCategory(afloat, new AssociationFloatProperty(0.5f));
      if (i % 2 == 0) { // 50
        container.addCategory(bint, new AssociationIntProperty(3));
        container.addCategory(bfloat, new AssociationFloatProperty(0.2f));
      }
      builder.setCategories(container).build(doc);
      writer.addDocument(doc);
    }
   
    taxoWriter.close();
    reader = writer.getReader();
View Full Code Here

      }

      // we do not alter indexing parameters!
      // a category document builder will add the categories to a document
      // once build() is called
      CategoryDocumentBuilder categoryDocBuilder = new EnhancementsDocumentBuilder(
          taxo, AssociationUtils.assocIndexingParams);
      categoryDocBuilder.setCategories(categoryContainer);

      // create a plain Lucene document and add some regular Lucene fields
      // to it
      Document doc = new Document();
      doc.add(new Field(SimpleUtils.TITLE, SimpleUtils.docTitles[docNum],
          Store.YES, Index.ANALYZED));
      doc.add(new Field(SimpleUtils.TEXT, SimpleUtils.docTexts[docNum],
          Store.NO, Index.ANALYZED));

      // invoke the category document builder for adding categories to the
      // document and,
      // as required, to the taxonomy index
      categoryDocBuilder.build(doc);

      // finally add the document to the index
      iw.addDocument(doc);

      nDocsAdded++;
View Full Code Here

    TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir);

    // a category document builder will add the categories to a document
    // once build() is called
    Document doc = new Document();
    indexWriter.addDocument(new EnhancementsDocumentBuilder(taxo,
        indexingParams).setCategoryPaths(categoryPaths).build(doc));

    IndexReader indexReader = indexWriter.getReader();
    indexWriter.close();
View Full Code Here

    TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir);

    // a category document builder will add the categories to a document
    // once build() is called
    Document doc = new Document();
    indexWriter.addDocument(new EnhancementsDocumentBuilder(taxo,
        indexingParams).setCategoryPaths(categoryPaths).build(doc));

    IndexReader indexReader = indexWriter.getReader();
    indexWriter.close();
View Full Code Here

    RandomIndexWriter w = new RandomIndexWriter(random, iDir,
        newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.KEYWORD, false)));
    DirectoryTaxonomyWriter taxoW = new DirectoryTaxonomyWriter(tDir);
   
    CategoryContainer cc = new CategoryContainer();
    EnhancementsDocumentBuilder builder = new EnhancementsDocumentBuilder(taxoW, iParams);
    for (int i = 1; i <= NUM_CATEGORIES; i++) {
      CategoryAttributeImpl ca = new CategoryAttributeImpl(new CategoryPath(Integer.toString(i)));
      ca.addProperty(new CustomProperty(i));
     
      cc.addCategory(ca);
    }
    builder.setCategories(cc);
    w.addDocument(builder.build(new Document()));
    taxoW.close();
    IndexReader reader = w.getReader();
    w.close();
   
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(tDir);
View Full Code Here

      }

      // we do not alter indexing parameters!
      // a category document builder will add the categories to a document
      // once build() is called
      CategoryDocumentBuilder categoryDocBuilder = new EnhancementsDocumentBuilder(
          taxo, AssociationUtils.assocIndexingParams);
      categoryDocBuilder.setCategories(categoryContainer);

      // create a plain Lucene document and add some regular Lucene fields
      // to it
      Document doc = new Document();
      doc.add(new TextField(SimpleUtils.TITLE, SimpleUtils.docTitles[docNum], Field.Store.YES));
      doc.add(new TextField(SimpleUtils.TEXT, SimpleUtils.docTexts[docNum], Field.Store.NO));

      // invoke the category document builder for adding categories to the
      // document and,
      // as required, to the taxonomy index
      categoryDocBuilder.build(doc);

      // finally add the document to the index
      iw.addDocument(doc);

      nDocsAdded++;
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.enhancements.EnhancementsDocumentBuilder

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.