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


Java DocValuesType类代码示例

本文整理汇总了Java中org.apache.lucene.index.DocValuesType的典型用法代码示例。如果您正苦于以下问题:Java DocValuesType类的具体用法?Java DocValuesType怎么用?Java DocValuesType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testDisableIndex

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
public void testDisableIndex() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "keyword").field("index", false).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", "1234")
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(1, fields.length);
    assertEquals(IndexOptions.NONE, fields[0].fieldType().indexOptions());
    assertEquals(DocValuesType.SORTED_SET, fields[0].fieldType().docValuesType());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:KeywordFieldMapperTests.java

示例2: testDisableDocValues

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
public void testDisableDocValues() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "keyword").field("doc_values", false).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", "1234")
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(1, fields.length);
    assertEquals(DocValuesType.NONE, fields[0].fieldType().docValuesType());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:KeywordFieldMapperTests.java

示例3: testNotIndexed

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
public void testNotIndexed() throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "scaled_float")
            .field("index", false).field("scaling_factor", 10.0).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", 123)
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(1, fields.length);
    IndexableField dvField = fields[0];
    assertEquals(DocValuesType.SORTED_NUMERIC, dvField.fieldType().docValuesType());
    assertEquals(1230, dvField.numericValue().longValue());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ScaledFloatFieldMapperTests.java

示例4: testNotIndexed

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
public void testNotIndexed() throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "date").field("index", false).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", "2016-03-11")
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(1, fields.length);
    IndexableField dvField = fields[0];
    assertEquals(DocValuesType.SORTED_NUMERIC, dvField.fieldType().docValuesType());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:DateFieldMapperTests.java

示例5: testStore

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
public void testStore() throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "date").field("store", true).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", "2016-03-11")
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(3, fields.length);
    IndexableField pointField = fields[0];
    assertEquals(1, pointField.fieldType().pointDimensionCount());
    IndexableField dvField = fields[1];
    assertEquals(DocValuesType.SORTED_NUMERIC, dvField.fieldType().docValuesType());
    IndexableField storedField = fields[2];
    assertTrue(storedField.fieldType().stored());
    assertEquals(1457654400000L, storedField.numericValue().longValue());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:DateFieldMapperTests.java

示例6: doTestDefaults

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
@Override
public void doTestDefaults(String type) throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", type).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", 123)
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(2, fields.length);
    IndexableField pointField = fields[0];
    assertEquals(1, pointField.fieldType().pointDimensionCount());
    assertFalse(pointField.fieldType().stored());
    assertEquals(123, pointField.numericValue().doubleValue(), 0d);
    IndexableField dvField = fields[1];
    assertEquals(DocValuesType.SORTED_NUMERIC, dvField.fieldType().docValuesType());
    assertFalse(dvField.fieldType().stored());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:NumberFieldMapperTests.java

示例7: doTestNotIndexed

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
@Override
public void doTestNotIndexed(String type) throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", type).field("index", false).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", 123)
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(1, fields.length);
    IndexableField dvField = fields[0];
    assertEquals(DocValuesType.SORTED_NUMERIC, dvField.fieldType().docValuesType());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:NumberFieldMapperTests.java

示例8: testNotIndexed

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
public void testNotIndexed() throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "ip").field("index", false).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", "::1")
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(1, fields.length);
    IndexableField dvField = fields[0];
    assertEquals(DocValuesType.SORTED_SET, dvField.fieldType().docValuesType());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:IpFieldMapperTests.java

示例9: testStore

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
public void testStore() throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "ip").field("store", true).endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));

    assertEquals(mapping, mapper.mappingSource().toString());

    ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", "::1")
            .endObject()
            .bytes());

    IndexableField[] fields = doc.rootDoc().getFields("field");
    assertEquals(3, fields.length);
    IndexableField pointField = fields[0];
    assertEquals(1, pointField.fieldType().pointDimensionCount());
    IndexableField dvField = fields[1];
    assertEquals(DocValuesType.SORTED_SET, dvField.fieldType().docValuesType());
    IndexableField storedField = fields[2];
    assertTrue(storedField.fieldType().stored());
    assertEquals(new BytesRef(InetAddressPoint.encode(InetAddress.getByName("::1"))),
            storedField.binaryValue());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:IpFieldMapperTests.java

示例10: wrap

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
static CodecReader wrap(CodecReader reader) throws IOException {
    final FieldInfos fieldInfos = reader.getFieldInfos();
    final FieldInfo versionInfo = fieldInfos.fieldInfo(VersionFieldMapper.NAME);
    if (versionInfo != null && versionInfo.getDocValuesType() != DocValuesType.NONE) {
        // the reader is a recent one, it has versions and they are stored
        // in a numeric doc values field
        return reader;
    }
    // The segment is an old one, look at the _uid field
    final Terms terms = reader.terms(UidFieldMapper.NAME);
    if (terms == null || !terms.hasPayloads()) {
        // The segment doesn't have an _uid field or doesn't have payloads
        // don't try to do anything clever. If any other segment has versions
        // all versions of this segment will be initialized to 0
        return reader;
    }
    // convert _uid payloads -> _version docvalues
    return new VersionFieldUpgrader(reader);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:VersionFieldUpgrader.java

示例11: build

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
@Override
public ParentFieldMapper build(BuilderContext context) {
    if (parentType == null) {
        throw new MapperParsingException("[_parent] field mapping must contain the [type] option");
    }
    parentJoinFieldType.setNames(new MappedFieldType.Names(joinField(documentType)));
    parentJoinFieldType.setFieldDataType(null);
    childJoinFieldType.setNames(new MappedFieldType.Names(joinField(parentType)));
    if (context.indexCreatedVersion().before(Version.V_2_0_0_beta1)) {
        childJoinFieldType.setHasDocValues(false);
        childJoinFieldType.setDocValuesType(DocValuesType.NONE);
        parentJoinFieldType.setHasDocValues(false);
        parentJoinFieldType.setDocValuesType(DocValuesType.NONE);
    }
    return new ParentFieldMapper(fieldType, parentJoinFieldType, childJoinFieldType, parentType, context.indexSettings());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:ParentFieldMapper.java

示例12: readDocValues

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
/**
 * @return the {@code NumericDocValues} for a given field
 * @throws IllegalArgumentException if this field is not indexed with numeric doc values
 */
public NumericDocValues readDocValues( String field )
{
    try
    {
        NumericDocValues dv = context.reader().getNumericDocValues( field );
        if ( dv == null )
        {
            FieldInfo fi = context.reader().getFieldInfos().fieldInfo( field );
            DocValuesType actual = null;
            if ( fi != null )
            {
                actual = fi.getDocValuesType();
            }
            throw new IllegalStateException(
                    "The field '" + field + "' is not indexed properly, expected NumericDV, but got '" +
                    actual + "'" );
        }
        return dv;
    }
    catch ( IOException e )
    {
        throw new RuntimeException( e );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:29,代码来源:DocValuesCollector.java

示例13: readDocValues

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
private Object readDocValues(String field, DocValuesType docValType, LeafReader atomicReader) throws IOException{
  Object docVals = null;
  if (docValType == DocValuesType.NUMERIC) {
    docVals = atomicReader.getNumericDocValues(field);
  }
  else if (docValType == DocValuesType.BINARY) {
    docVals = atomicReader.getBinaryDocValues(field);
  }
  else if (docValType == DocValuesType.SORTED) {
    docVals = atomicReader.getSortedDocValues(field);
  }
  else if (docValType == DocValuesType.SORTED_NUMERIC) {
    docVals = atomicReader.getSortedNumericDocValues(field);
  }
  else if (docValType == DocValuesType.SORTED_SET) {
    docVals = atomicReader.getSortedSetDocValues(field);
  }
  return docVals;
}
 
开发者ID:javasoze,项目名称:clue,代码行数:20,代码来源:DocValCommand.java

示例14: showDocId

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
private void showDocId(int docid, int docBase, String field,
    LeafReader atomicReader, PrintStream out, int segmentid)
    throws Exception {
  FieldInfo finfo = atomicReader.getFieldInfos().fieldInfo(field);

  if (finfo == null || finfo.getDocValuesType() == DocValuesType.NONE) {
    out.println("docvalue does not exist for field: " + field);
    return;
  }

  
  DocValuesType docValType = finfo.getDocValuesType();
  BytesRef bref = new BytesRef();
  
  showDocId(docid, docBase, readDocValues(field, docValType, atomicReader), docValType, bref, out, segmentid);
}
 
开发者ID:javasoze,项目名称:clue,代码行数:17,代码来源:DocValCommand.java

示例15: createQueryBuilderFieldBuilder

import org.apache.lucene.index.DocValuesType; //导入依赖的package包/类
static BinaryFieldMapper createQueryBuilderFieldBuilder(BuilderContext context) {
    BinaryFieldMapper.Builder builder = new BinaryFieldMapper.Builder(QUERY_BUILDER_FIELD_NAME);
    builder.docValues(true);
    builder.indexOptions(IndexOptions.NONE);
    builder.store(false);
    builder.fieldType().setDocValuesType(DocValuesType.BINARY);
    return builder.build(context);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:PercolatorFieldMapper.java


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