List of usage examples for org.apache.lucene.document FieldType docValuesType
DocValuesType docValuesType
To view the source code for org.apache.lucene.document FieldType docValuesType.
Click Source Link
From source file:org.apache.solr.legacy.BBoxStrategy.java
License:Apache License
/** * Creates this strategy./* www . ja v a 2s . c o m*/ * {@code fieldType} is used to customize the indexing options of the 4 number fields, and to a lesser degree the XDL * field too. Search requires pointValues (or legacy numerics), and relevancy requires docValues. If these features * aren't needed then disable them. */ public BBoxStrategy(SpatialContext ctx, String fieldNamePrefix, FieldType fieldType) { super(ctx, fieldNamePrefix); field_bbox = fieldNamePrefix; field_minX = fieldNamePrefix + SUFFIX_MINX; field_maxX = fieldNamePrefix + SUFFIX_MAXX; field_minY = fieldNamePrefix + SUFFIX_MINY; field_maxY = fieldNamePrefix + SUFFIX_MAXY; field_xdl = fieldNamePrefix + SUFFIX_XDL; fieldType.freeze(); this.optionsFieldType = fieldType; int numQuads = 0; if ((this.hasStored = fieldType.stored())) { numQuads++; } if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) { numQuads++; } if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) { numQuads++; } if (fieldType.indexOptions() != IndexOptions.NONE && fieldType instanceof LegacyFieldType && ((LegacyFieldType) fieldType).numericType() != null) { if (hasPointVals) { throw new IllegalArgumentException("pointValues and LegacyNumericType are mutually exclusive"); } final LegacyFieldType legacyType = (LegacyFieldType) fieldType; if (legacyType.numericType() != LegacyNumericType.DOUBLE) { throw new IllegalArgumentException(getClass() + " does not support " + legacyType.numericType()); } numQuads++; legacyNumericFieldType = new LegacyFieldType(LegacyDoubleField.TYPE_NOT_STORED); legacyNumericFieldType.setNumericPrecisionStep(legacyType.numericPrecisionStep()); legacyNumericFieldType.freeze(); } else { legacyNumericFieldType = null; } if (hasPointVals || legacyNumericFieldType != null) { // if we have an index... xdlFieldType = new FieldType(StringField.TYPE_NOT_STORED); xdlFieldType.setIndexOptions(IndexOptions.DOCS); xdlFieldType.freeze(); } else { xdlFieldType = null; } this.fieldsLen = numQuads * 4 + (xdlFieldType != null ? 1 : 0); }
From source file:org.apache.solr.legacy.PointVectorStrategy.java
License:Apache License
/** * Create a new instance configured with the provided FieldType options. See {@link #DEFAULT_FIELDTYPE}. * a field type is used to articulate the desired options (namely pointValues, docValues, stored). Legacy numerics * is configurable this way too./*from w w w .jav a 2s. c om*/ */ public PointVectorStrategy(SpatialContext ctx, String fieldNamePrefix, FieldType fieldType) { super(ctx, fieldNamePrefix); this.fieldNameX = fieldNamePrefix + SUFFIX_X; this.fieldNameY = fieldNamePrefix + SUFFIX_Y; int numPairs = 0; if ((this.hasStored = fieldType.stored())) { numPairs++; } if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) { numPairs++; } if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) { numPairs++; } if (fieldType.indexOptions() != IndexOptions.NONE && fieldType instanceof LegacyFieldType && ((LegacyFieldType) fieldType).numericType() != null) { if (hasPointVals) { throw new IllegalArgumentException("pointValues and LegacyNumericType are mutually exclusive"); } final LegacyFieldType legacyType = (LegacyFieldType) fieldType; if (legacyType.numericType() != LegacyNumericType.DOUBLE) { throw new IllegalArgumentException(getClass() + " does not support " + legacyType.numericType()); } numPairs++; legacyNumericFieldType = new LegacyFieldType(LegacyDoubleField.TYPE_NOT_STORED); legacyNumericFieldType.setNumericPrecisionStep(legacyType.numericPrecisionStep()); legacyNumericFieldType.freeze(); } else { legacyNumericFieldType = null; } this.fieldsLen = numPairs * 2; }
From source file:org.hibernate.search.indexes.serialization.impl.LuceneWorkSerializerImpl.java
License:LGPL
private void serializeDocument(Document document, Serializer serializer) { final List<IndexableField> docFields = document.getFields(); serializer.fields(docFields);// w ww .j av a 2s.c om for (IndexableField fieldable : docFields) { final FieldType fieldType = (FieldType) fieldable.fieldType(); final NumericType numericType = fieldType.numericType(); if (numericType != null) { serializeNumericField(serializer, fieldable, fieldType, numericType); continue; } DocValuesType docValuesType = fieldType.docValuesType(); if (docValuesType != null && docValuesType != DocValuesType.NONE) { serializeDocValues(serializer, (Field) fieldable); continue; } if (fieldable instanceof Field) { serializeField(serializer, (Field) fieldable); } else { throw log.cannotSerializeCustomField(fieldable.getClass()); } } serializer.addDocument(); }
From source file:org.hibernate.search.test.util.SerializationTestHelper.java
License:LGPL
private static void assertFieldType(FieldType copy, FieldType original) { assertThat(copy.omitNorms()).isEqualTo(original.omitNorms()); assertThat(copy.storeTermVectorOffsets()).isEqualTo(original.storeTermVectorOffsets()); assertThat(copy.storeTermVectorPayloads()).isEqualTo(original.storeTermVectorPayloads()); assertThat(copy.storeTermVectorOffsets()).isEqualTo(original.storeTermVectorOffsets()); assertThat(copy.docValuesType()).isEqualTo(original.docValuesType()); assertThat(copy.indexOptions()).isEqualTo(original.indexOptions()); assertThat(copy.numericPrecisionStep()).isEqualTo(original.numericPrecisionStep()); assertThat(copy.numericType()).isEqualTo(original.numericType()); assertThat(copy.stored()).isEqualTo(original.stored()); assertThat(copy.storeTermVectors()).isEqualTo(original.storeTermVectors()); assertThat(copy.tokenized()).isEqualTo(original.tokenized()); assertThat(copy.toString()).isEqualTo(original.toString()); }