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


Java AtomicReader.getFieldInfos方法代码示例

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


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

示例1: testDocValues

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public void testDocValues() throws IOException {
  assertU(adoc("id", "1", "floatdv", "4.5", "intdv", "-1", "intdv", "3", "stringdv", "value1", "stringdv", "value2"));
  assertU(commit());
  try (SolrCore core = h.getCoreInc()) {
    final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true);
    final SolrIndexSearcher searcher = searcherRef.get();
    try {
      final AtomicReader reader = searcher.getAtomicReader();
      assertEquals(1, reader.numDocs());
      final FieldInfos infos = reader.getFieldInfos();
      assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("stringdv").getDocValuesType());
      assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("floatdv").getDocValuesType());
      assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("intdv").getDocValuesType());

      SortedSetDocValues dv = reader.getSortedSetDocValues("stringdv");
      dv.setDocument(0);
      assertEquals(0, dv.nextOrd());
      assertEquals(1, dv.nextOrd());
      assertEquals(SortedSetDocValues.NO_MORE_ORDS, dv.nextOrd());
    } finally {
      searcherRef.decref();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:DocValuesMultiTest.java

示例2: LuceneIndex

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public LuceneIndex(File path, boolean readOnly, Analyzer analyzer, Index... indices) throws Exception {
	// fieldsToSkip.add(Variable.CONTENT);
	fieldsToSkip.add(Variable.BYTES);
	this.readOnly = readOnly;

	if (analyzer != null) {
		this.analyzer = analyzer;
	} else {
		this.analyzer = new StandardAnalyzer(LUCENEVERSION);
	}

	if (indices.length == 1) {
		getAlgorithmMap().put("Index0", (Algorithm) indices[0]);
		setLabel(((Algorithm) indices[0]).getLabel());
	} else if (indices.length > 1) {
		MultiIndex multiIndex = new MultiIndex(indices);
		getAlgorithmMap().put("Index0", multiIndex);
		setLabel(multiIndex.getLabel());
	}

	if (path == null) {
		path = File.createTempFile("lucene", "");
		path.delete();
		path.mkdir();
		path.deleteOnExit();
		readOnly = false;
	}

	fields.add(Sample.ID);

	this.path = path;

	directory = FSDirectory.open(path);
	if (DirectoryReader.indexExists(directory)) {
		if (!readOnly) {
			if (IndexWriter.isLocked(directory)) {
				IndexWriter.unlock(directory);
			}
			indexWriter = new IndexWriter(directory, new IndexWriterConfig(LUCENEVERSION, analyzer));
		}

		for (AtomicReaderContext rc : getIndexSearcher().getIndexReader().leaves()) {
			AtomicReader ar = rc.reader();
			FieldInfos fis = ar.getFieldInfos();
			for (FieldInfo fi : fis) {
				fields.add(fi.name);
			}
		}

	} else if (!readOnly) {
		indexWriter = new IndexWriter(directory,
				new IndexWriterConfig(LUCENEVERSION, analyzer).setOpenMode(OpenMode.CREATE));
	}

	setSamples(new LuceneSampleMap(this));

}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:58,代码来源:LuceneIndex.java

示例3: testDocValues

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public void testDocValues() throws IOException {
  assertU(adoc("id", "1"));
  assertU(commit());
  try (SolrCore core = h.getCoreInc()) {
    final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true);
    final SolrIndexSearcher searcher = searcherRef.get();
    try {
      final AtomicReader reader = searcher.getAtomicReader();
      assertEquals(1, reader.numDocs());
      final FieldInfos infos = reader.getFieldInfos();
      assertEquals(DocValuesType.NUMERIC, infos.fieldInfo("floatdv").getDocValuesType());
      assertEquals(DocValuesType.NUMERIC, infos.fieldInfo("intdv").getDocValuesType());
      assertEquals(DocValuesType.NUMERIC, infos.fieldInfo("doubledv").getDocValuesType());
      assertEquals(DocValuesType.NUMERIC, infos.fieldInfo("longdv").getDocValuesType());
      assertEquals(DocValuesType.SORTED, infos.fieldInfo("stringdv").getDocValuesType());

      assertEquals((long) Float.floatToIntBits(1), reader.getNumericDocValues("floatdv").get(0));
      assertEquals(2L, reader.getNumericDocValues("intdv").get(0));
      assertEquals(Double.doubleToLongBits(3), reader.getNumericDocValues("doubledv").get(0));
      assertEquals(4L, reader.getNumericDocValues("longdv").get(0));

      final IndexSchema schema = core.getLatestSchema();
      final SchemaField floatDv = schema.getField("floatdv");
      final SchemaField intDv = schema.getField("intdv");
      final SchemaField doubleDv = schema.getField("doubledv");
      final SchemaField longDv = schema.getField("longdv");

      FunctionValues values = floatDv.getType().getValueSource(floatDv, null).getValues(null, searcher.getAtomicReader().leaves().get(0));
      assertEquals(1f, values.floatVal(0), 0f);
      assertEquals(1f, values.objectVal(0));
      values = intDv.getType().getValueSource(intDv, null).getValues(null, searcher.getAtomicReader().leaves().get(0));
      assertEquals(2, values.intVal(0));
      assertEquals(2, values.objectVal(0));
      values = doubleDv.getType().getValueSource(doubleDv, null).getValues(null, searcher.getAtomicReader().leaves().get(0));
      assertEquals(3d, values.doubleVal(0), 0d);
      assertEquals(3d, values.objectVal(0));
      values = longDv.getType().getValueSource(longDv, null).getValues(null, searcher.getAtomicReader().leaves().get(0));
      assertEquals(4L, values.longVal(0));
      assertEquals(4L, values.objectVal(0));
    } finally {
      searcherRef.decref();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:45,代码来源:DocValuesTest.java


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