当前位置: 首页>>代码示例>>Java>>正文


Java FacetsConfig.setHierarchical方法代码示例

本文整理汇总了Java中org.apache.lucene.facet.FacetsConfig.setHierarchical方法的典型用法代码示例。如果您正苦于以下问题:Java FacetsConfig.setHierarchical方法的具体用法?Java FacetsConfig.setHierarchical怎么用?Java FacetsConfig.setHierarchical使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.facet.FacetsConfig的用法示例。


在下文中一共展示了FacetsConfig.setHierarchical方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
  super.setUp();
  publishIndexDir = newDirectory();
  publishTaxoDir = newDirectory();
  handlerIndexDir = newMockDirectory();
  handlerTaxoDir = newMockDirectory();
  clientWorkDir = createTempDir("replicationClientTest");
  sourceDirFactory = new PerSessionDirectoryFactory(clientWorkDir);
  replicator = new LocalReplicator();
  callback = new IndexAndTaxonomyReadyCallback(handlerIndexDir, handlerTaxoDir);
  handler = new IndexAndTaxonomyReplicationHandler(handlerIndexDir, handlerTaxoDir, callback);
  client = new ReplicationClient(replicator, handler, sourceDirFactory);
  
  IndexWriterConfig conf = newIndexWriterConfig(null);
  conf.setIndexDeletionPolicy(new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy()));
  publishIndexWriter = new IndexWriter(publishIndexDir, conf);
  publishTaxoWriter = new SnapshotDirectoryTaxonomyWriter(publishTaxoDir);
  config = new FacetsConfig();
  config.setHierarchical("A", true);
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:IndexAndTaxonomyReplicationClientTest.java

示例2: testNoHierarchy

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
public void testNoHierarchy() throws Exception {
  Directory dir = newDirectory();
  Directory taxoDir = newDirectory();
  
  TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
  FacetsConfig config = new FacetsConfig();
  config.setHierarchical("a", true);
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);

  Document doc = new Document();
  doc.add(new IntAssociationFacetField(14, "a", "x"));
  try {
    writer.addDocument(config.build(taxoWriter, doc));
    fail("did not hit expected exception");
  } catch (IllegalArgumentException exc) {
    // expected
  }
  IOUtils.close(writer, taxoWriter, dir, taxoDir);
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TestTaxonomyFacetAssociations.java

示例3: setUp

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    LuceneSettings settingsSummary = new LuceneSettings();
    FacetsConfig facetsConfig = settingsSummary.facetsConfig;
    String dimName = "untokenized.ggc:kmc0500par103.uri.byOntology";
    facetsConfig.setHierarchical(dimName, true);
    facetsConfig.setMultiValued(dimName, true);
    facetsConfig.setIndexFieldName(dimName, "$facets_ggc:kmc0500par103.uri.byOntology");

    LuceneSettings settingsHolding = new LuceneSettings();
    LuceneSettings settingsRank = new LuceneSettings();
    settingsRank.similarity = new TermFrequencySimilarity();
    this.luceneSummary = new Lucene("summary", new File("/data/NBC-340-lucene/lucene-summary").toPath(), settingsSummary);
    Lucene luceneHolding = new Lucene("holding", new File("/data/NBC-340-lucene/lucene-holding").toPath(), settingsHolding);
    Lucene luceneRank = new Lucene("rank", new File("/data/NBC-340-lucene/lucene-rank").toPath(), settingsRank);
    this.multiLucene = new MultiLucene(Arrays.asList(luceneSummary, luceneHolding, luceneRank));
}
 
开发者ID:seecr,项目名称:meresco-lucene,代码行数:20,代码来源:RealIndexTest.java

示例4: configure

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
@Override
public void configure(FacetsConfig config) {
  for(int i=0;i<maxDims;i++) {
    config.setHierarchical(Integer.toString(i), true);
    config.setMultiValued(Integer.toString(i), true);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:RandomFacetSource.java

示例5: IndexAndTaxonomyReadyCallback

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
public IndexAndTaxonomyReadyCallback(Directory indexDir, Directory taxoDir) throws IOException {
  this.indexDir = indexDir;
  this.taxoDir = taxoDir;
  config = new FacetsConfig();
  config.setHierarchical("A", true);
  if (DirectoryReader.indexExists(indexDir)) {
    indexReader = DirectoryReader.open(indexDir);
    lastIndexGeneration = indexReader.getIndexCommit().getGeneration();
    taxoReader = new DirectoryTaxonomyReader(taxoDir);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:IndexAndTaxonomyReplicationClientTest.java

示例6: getConfig

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
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;
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestTaxonomyFacetCounts2.java

示例7: testRollupValues

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
public void testRollupValues() throws Exception {
  Directory indexDir = newDirectory();
  Directory taxoDir = newDirectory();

  DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
  IndexWriter iw = new IndexWriter(indexDir, newIndexWriterConfig(new MockAnalyzer(random())));
  FacetsConfig config = new FacetsConfig();
  config.setHierarchical("a", true);
  //config.setRequireDimCount("a", true);
  
  for (int i = 0; i < 4; i++) {
    Document doc = new Document();
    doc.add(new NumericDocValuesField("price", (i+1)));
    doc.add(new FacetField("a", Integer.toString(i % 2), "1"));
    iw.addDocument(config.build(taxoWriter, doc));
  }
  
  DirectoryReader r = DirectoryReader.open(iw, true);
  DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);

  ValueSource valueSource = new LongFieldSource("price");
  FacetsCollector sfc = new FacetsCollector();
  newSearcher(r).search(new MatchAllDocsQuery(), sfc);
  Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, sfc, valueSource);
  
  assertEquals("dim=a path=[] value=10.0 childCount=2\n  1 (6.0)\n  0 (4.0)\n", facets.getTopChildren(10, "a").toString());
  
  IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:TestTaxonomyFacetSumValueSource.java

示例8: testMultiValuedHierarchy

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
public void testMultiValuedHierarchy() throws Exception {
  Directory dir = newDirectory();
  Directory taxoDir = newDirectory();
  DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE);
  FacetsConfig config = new FacetsConfig();
  config.setHierarchical("a", true);
  config.setMultiValued("a", true);
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);

  Document doc = new Document();
  doc.add(newTextField("field", "text", Field.Store.NO));
  doc.add(new FacetField("a", "path", "x"));
  doc.add(new FacetField("a", "path", "y"));
  writer.addDocument(config.build(taxoWriter, doc));

  // NRT open
  IndexSearcher searcher = newSearcher(writer.getReader());

  // NRT open
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
  
  // Aggregate the facet counts:
  FacetsCollector c = new FacetsCollector();

  // MatchAllDocsQuery is for "browsing" (counts facets
  // for all non-deleted docs in the index); normally
  // you'd use a "normal" query, and use MultiCollector to
  // wrap collecting the "normal" hits and also facets:
  searcher.search(new MatchAllDocsQuery(), c);
  Facets facets = getTaxonomyFacetCounts(taxoReader, config, c);

  try {
    facets.getSpecificValue("a");
    fail("didn't hit expected exception");
  } catch (IllegalArgumentException iae) {
    // expected
  }

  FacetResult result = facets.getTopChildren(10, "a");
  assertEquals(1, result.labelValues.length);
  assertEquals(1, result.labelValues[0].value.intValue());

  IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
}
 
开发者ID:europeana,项目名称:search,代码行数:45,代码来源:TestTaxonomyFacetCounts.java

示例9: testRequireDimCount

import org.apache.lucene.facet.FacetsConfig; //导入方法依赖的package包/类
public void testRequireDimCount() throws Exception {
  Directory dir = newDirectory();
  Directory taxoDir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE);

  FacetsConfig config = new FacetsConfig();
  config.setRequireDimCount("dim", true);

  config.setMultiValued("dim2", true);
  config.setRequireDimCount("dim2", true);

  config.setMultiValued("dim3", true);
  config.setHierarchical("dim3", true);
  config.setRequireDimCount("dim3", true);

  Document doc = new Document();
  doc.add(newTextField("field", "text", Field.Store.NO));
  doc.add(new FacetField("dim", "a"));
  doc.add(new FacetField("dim2", "a"));
  doc.add(new FacetField("dim2", "b"));
  doc.add(new FacetField("dim3", "a", "b"));
  doc.add(new FacetField("dim3", "a", "c"));
  writer.addDocument(config.build(taxoWriter, doc));

  // NRT open
  IndexSearcher searcher = newSearcher(writer.getReader());

  // NRT open
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);

  FacetsCollector c = new FacetsCollector();
  searcher.search(new MatchAllDocsQuery(), c);
  
  Facets facets = getTaxonomyFacetCounts(taxoReader, config, c);
  assertEquals(1, facets.getTopChildren(10, "dim").value);
  assertEquals(1, facets.getTopChildren(10, "dim2").value);
  assertEquals(1, facets.getTopChildren(10, "dim3").value);
  try {
    assertEquals(1, facets.getSpecificValue("dim"));
    fail("didn't hit expected exception");
  } catch (IllegalArgumentException iae) {
    // expected
  }
  assertEquals(1, facets.getSpecificValue("dim2"));
  assertEquals(1, facets.getSpecificValue("dim3"));
  IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
}
 
开发者ID:europeana,项目名称:search,代码行数:49,代码来源:TestTaxonomyFacetCounts.java


注:本文中的org.apache.lucene.facet.FacetsConfig.setHierarchical方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。