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


Java SortedDocValues.get方法代码示例

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


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

示例1: getParentId

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public static String getParentId(ParentFieldMapper fieldMapper, LeafReader reader, int docId) {
    try {
        SortedDocValues docValues = reader.getSortedDocValues(fieldMapper.name());
        if (docValues == null) {
            // hit has no _parent field.
            return null;
        }
        BytesRef parentId = docValues.get(docId);
        return parentId.length > 0 ? parentId.utf8ToString() : null;
    } catch (IOException e) {
        throw ExceptionsHelper.convertToElastic(e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:ParentFieldSubFetchPhase.java

示例2: testSortedDocValuesField

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
@Test
public void testSortedDocValuesField() throws Exception {
  SortedDocValues dv = reader.getSortedDocValues(SORTED_DV_FIELD);
  int maxDoc = reader.maxDoc();
  for (int i = 0; i < maxDoc; i++) {
    final BytesRef bytes = dv.get(i);
    assertEquals("incorrect sorted DocValues for doc " + i, sortedValues[i].toString(), bytes.utf8ToString());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:SorterTestBase.java

示例3: write

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public void write(int docId, AtomicReader reader, Writer out) throws IOException {
  SortedDocValues vals = reader.getSortedDocValues(this.field);
  BytesRef ref = vals.get(docId);
  fieldType.indexedToReadable(ref, cref);
  out.write('"');
  out.write(this.field);
  out.write('"');
  out.write(":");
  out.write('"');
  out.write(cref.toString());
  out.write('"');
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SortingResponseWriter.java

示例4: runGisDocValueTest

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
protected void runGisDocValueTest(String s) throws IOException {
  DirectoryReader reader = DirectoryReader.open(_dir);
  AtomicReader atomicReader = reader.leaves().get(0).reader();
  SortedDocValues sortedDocValues = atomicReader.getSortedDocValues("fam.geo");
  BytesRef result = new BytesRef();
  sortedDocValues.get(0, result);
  assertEquals(s, result.utf8ToString());
  System.out.println(result.utf8ToString());
  reader.close();
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:11,代码来源:BaseSpatialFieldTypeDefinitionTest.java

示例5: testNonexistantFields

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public void testNonexistantFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms", true);
  BytesRef scratch = binaries.get(0);
  assertEquals(0, scratch.length);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  scratch = sorted.get(0);
  assertEquals(0, scratch.length);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:54,代码来源:TestFieldCache.java

示例6: testNonIndexedFields

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public void testNonIndexedFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new StoredField("bogusbytes", "bogus"));
  doc.add(new StoredField("bogusshorts", "bogus"));
  doc.add(new StoredField("bogusints", "bogus"));
  doc.add(new StoredField("boguslongs", "bogus"));
  doc.add(new StoredField("bogusfloats", "bogus"));
  doc.add(new StoredField("bogusdoubles", "bogus"));
  doc.add(new StoredField("bogusterms", "bogus"));
  doc.add(new StoredField("bogustermsindex", "bogus"));
  doc.add(new StoredField("bogusmultivalued", "bogus"));
  doc.add(new StoredField("bogusbits", "bogus"));
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms", true);
  BytesRef scratch = binaries.get(0);
  assertEquals(0, scratch.length);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  scratch = sorted.get(0);
  assertEquals(0, scratch.length);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:64,代码来源:TestFieldCache.java


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