List of usage examples for org.apache.lucene.document FieldType indexOptions
IndexOptions indexOptions
To view the source code for org.apache.lucene.document FieldType indexOptions.
Click Source Link
From source file:com.qwazr.search.field.CustomField.java
License:Apache License
protected CustomField(String name, FieldType type, Object value) { super(name, type); if (!type.stored() && type.indexOptions() == IndexOptions.NONE) throw new IllegalArgumentException( "it doesn't make sense to have a field that " + "is neither indexed nor stored"); if (value == null) throw new IllegalArgumentException("value cannot be null"); this.fieldsData = value; }
From source file:com.sindicetech.siren.solr.schema.ExtendedJsonField.java
License:Open Source License
@Override protected IndexableField createField(final String name, final String val, final org.apache.lucene.document.FieldType type, final float boost) { if (!type.indexed()) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "ExtendedJsonField instances must be indexed: " + name); }/*w w w. j ava 2s.c o m*/ if (!type.tokenized()) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "ExtendedJsonField instances must be tokenised: " + name); } if (!type.omitNorms()) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "ExtendedJsonField instances must omit norms: " + name); } if (!type.indexOptions().equals(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "ExtendedJsonField instances must not omit term " + "frequencies and positions: " + name); } if (type.storeTermVectors()) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "ExtendedJsonField instances can not store term vectors: " + name); } return super.createField(name, val, type, boost); }
From source file:org.apache.solr.legacy.BBoxStrategy.java
License:Apache License
/** * Creates this strategy./*from ww w.ja va 2 s. co 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.//ww w. j ava2s. 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.elasticsearch.index.mapper.core.AbstractFieldMapper.java
License:Apache License
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { builder.field("type", contentType()); if (includeDefaults || !names.name().equals(names.indexNameClean())) { builder.field("index_name", names.indexNameClean()); }/*from www. j a v a2 s .c o m*/ if (includeDefaults || boost != 1.0f) { builder.field("boost", boost); } FieldType defaultFieldType = defaultFieldType(); if (includeDefaults || fieldType.indexed() != defaultFieldType.indexed() || fieldType.tokenized() != defaultFieldType.tokenized()) { builder.field("index", indexTokenizeOptionToString(fieldType.indexed(), fieldType.tokenized())); } if (includeDefaults || fieldType.stored() != defaultFieldType.stored()) { builder.field("store", fieldType.stored()); } if (includeDefaults || hasDocValues() != Defaults.DOC_VALUES) { builder.field(TypeParsers.DOC_VALUES, docValues); } if (includeDefaults || fieldType.storeTermVectors() != defaultFieldType.storeTermVectors()) { builder.field("term_vector", termVectorOptionsToString(fieldType)); } if (includeDefaults || fieldType.omitNorms() != defaultFieldType.omitNorms() || normsLoading != null) { builder.startObject("norms"); if (includeDefaults || fieldType.omitNorms() != defaultFieldType.omitNorms()) { builder.field("enabled", !fieldType.omitNorms()); } if (normsLoading != null) { builder.field(Loading.KEY, normsLoading); } builder.endObject(); } if (includeDefaults || fieldType.indexOptions() != defaultFieldType.indexOptions()) { builder.field("index_options", indexOptionToString(fieldType.indexOptions())); } if (indexAnalyzer == null && searchAnalyzer == null) { if (includeDefaults) { builder.field("analyzer", "default"); } } else if (indexAnalyzer == null) { // searchAnalyzer != null if (includeDefaults || (!searchAnalyzer.name().startsWith("_") && !searchAnalyzer.name().equals("default"))) { builder.field("search_analyzer", searchAnalyzer.name()); } } else if (searchAnalyzer == null) { // indexAnalyzer != null if (includeDefaults || (!indexAnalyzer.name().startsWith("_") && !indexAnalyzer.name().equals("default"))) { builder.field("index_analyzer", indexAnalyzer.name()); } } else if (indexAnalyzer.name().equals(searchAnalyzer.name())) { // indexAnalyzer == searchAnalyzer if (includeDefaults || (!indexAnalyzer.name().startsWith("_") && !indexAnalyzer.name().equals("default"))) { builder.field("analyzer", indexAnalyzer.name()); } } else { // both are there but different if (includeDefaults || (!indexAnalyzer.name().startsWith("_") && !indexAnalyzer.name().equals("default"))) { builder.field("index_analyzer", indexAnalyzer.name()); } if (includeDefaults || (!searchAnalyzer.name().startsWith("_") && !searchAnalyzer.name().equals("default"))) { builder.field("search_analyzer", searchAnalyzer.name()); } } if (postingsFormat != null) { if (includeDefaults || !postingsFormat.name().equals(defaultPostingFormat())) { builder.field("postings_format", postingsFormat.name()); } } else if (includeDefaults) { String format = defaultPostingFormat(); if (format == null) { format = PostingsFormatService.DEFAULT_FORMAT; } builder.field("postings_format", format); } if (docValuesFormat != null) { if (includeDefaults || !docValuesFormat.name().equals(defaultDocValuesFormat())) { builder.field(DOC_VALUES_FORMAT, docValuesFormat.name()); } } else if (includeDefaults) { String format = defaultDocValuesFormat(); if (format == null) { format = DocValuesFormatService.DEFAULT_FORMAT; } builder.field(DOC_VALUES_FORMAT, format); } if (similarity() != null) { builder.field("similarity", similarity().name()); } else if (includeDefaults) { builder.field("similariry", SimilarityLookupService.DEFAULT_SIMILARITY); } if (customFieldDataSettings != null) { builder.field("fielddata", (Map) customFieldDataSettings.getAsMap()); } else if (includeDefaults) { builder.field("fielddata", (Map) fieldDataType.getSettings().getAsMap()); } multiFields.toXContent(builder, params); if (copyTo != null) { copyTo.toXContent(builder, params); } }
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()); }