protected void doXContentDocValues(XContentBuilder builder, boolean includeDefaults) throws IOException { if (includeDefaults || defaultFieldType.hasDocValues() != fieldType().hasDocValues()) { builder.field("doc_values", fieldType().hasDocValues()); } }
/** @throws IllegalArgumentException if the fielddata is not supported on this type. * An IllegalArgumentException is needed in order to return an http error 400 * when this error occurs in a request. see: {@link org.elasticsearch.ExceptionsHelper#status} **/ protected final void failIfNoDocValues() { if (hasDocValues() == false) { throw new IllegalArgumentException("Can't load fielddata on [" + name() + "] because fielddata is unsupported on fields of type [" + typeName() + "]. Use doc values instead."); } }
protected Builder(String name, MappedFieldType fieldType, MappedFieldType defaultFieldType) { super(name); this.fieldType = fieldType.clone(); this.defaultFieldType = defaultFieldType.clone(); this.defaultOptions = fieldType.indexOptions(); // we have to store it the fieldType is mutable this.docValuesSet = fieldType.hasDocValues(); multiFieldsBuilder = new MultiFields.Builder(); }
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } fields.add(new Field(fieldType().name(), context.sourceToParse().type(), fieldType())); if (fieldType().hasDocValues()) { fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.sourceToParse().type()))); } }
protected MappedFieldType(MappedFieldType ref) { super(ref); this.name = ref.name(); this.boost = ref.boost(); this.docValues = ref.hasDocValues(); this.indexAnalyzer = ref.indexAnalyzer(); this.searchAnalyzer = ref.searchAnalyzer(); this.searchQuoteAnalyzer = ref.searchQuoteAnalyzer(); this.similarity = ref.similarity(); this.nullValue = ref.nullValue(); this.nullValueAsString = ref.nullValueAsString(); this.eagerGlobalOrdinals = ref.eagerGlobalOrdinals; }
conflicts.add("mapper [" + name() + "] has different [store] values"); if (hasDocValues() != other.hasDocValues()) { conflicts.add("mapper [" + name() + "] has different [doc_values] values");
if (fieldType.hasDocValues() == false) { throw new SearchContextException(context, "cannot collapse on field `" + field + "` without `doc_values`");
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { if (!fieldType().stored() && !fieldType().hasDocValues()) { return; if (fieldType().hasDocValues()) { CustomBinaryDocValuesField field = (CustomBinaryDocValuesField) context.doc().getByKey(fieldType().name()); if (field == null) {
protected void doXContentDocValues(XContentBuilder builder, boolean includeDefaults) throws IOException { if (includeDefaults || defaultFieldType.hasDocValues() != fieldType().hasDocValues()) { builder.field("doc_values", fieldType().hasDocValues()); } }
protected void doXContentDocValues(XContentBuilder builder, boolean includeDefaults) throws IOException { if (includeDefaults || defaultFieldType.hasDocValues() != fieldType().hasDocValues()) { builder.field("doc_values", fieldType().hasDocValues()); } }
protected void doXContentDocValues(XContentBuilder builder, boolean includeDefaults) throws IOException { if (includeDefaults || defaultFieldType.hasDocValues() != fieldType().hasDocValues()) { builder.field("doc_values", fieldType().hasDocValues()); } }
@Override protected Query doToQuery(QueryShardContext shardContext) throws IOException { MappedFieldType fieldType = shardContext.fieldMapper(fieldName); if (fieldType == null) { if (ignoreUnmapped) { return new MatchNoDocsQuery(); } else { throw new QueryShardException(shardContext, "failed to find geo_point field [" + fieldName + "]"); } } if (!(fieldType instanceof GeoPointFieldType)) { throw new QueryShardException(shardContext, "field [" + fieldName + "] is not a geo_point field"); } QueryValidationException exception = checkLatLon(); if (exception != null) { throw new QueryShardException(shardContext, "couldn't validate latitude/ longitude values", exception); } if (GeoValidationMethod.isCoerce(validationMethod)) { GeoUtils.normalizePoint(center, true, true); } Query query = LatLonPoint.newDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); if (fieldType.hasDocValues()) { Query dvQuery = LatLonDocValuesField.newSlowDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); query = new IndexOrDocValuesQuery(query, dvQuery); } return query; }
} else if (type.hasDocValues() == false) { throw new IllegalArgumentException("cannot load numeric doc values on " + field); } else {
boolean docValued = fieldType.hasDocValues(); boolean stored = fieldType.stored(); fields.addAll(fieldType().rangeType.createFields(context, name(), range, indexed, docValued, stored));
context.doc().add(new StoredField(fieldType().name(), point.toString())); if (fieldType.hasDocValues()) { context.doc().add(new LatLonDocValuesField(fieldType().name(), point.lat(), point.lon())); } else if (fieldType().stored() || fieldType().indexOptions() != IndexOptions.NONE) {
if (fieldType.hasDocValues()) { Query dvQuery = LatLonDocValuesField.newSlowBoxQuery(fieldType.name(), luceneBottomRight.getLat(), luceneTopLeft.getLat(),
protected Builder(String name, MappedFieldType fieldType, MappedFieldType defaultFieldType) { super(name); this.fieldType = fieldType.clone(); this.defaultFieldType = defaultFieldType.clone(); this.defaultOptions = fieldType.indexOptions(); // we have to store it the fieldType is mutable this.docValuesSet = fieldType.hasDocValues(); multiFieldsBuilder = new MultiFields.Builder(); }
protected TextFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, int positionIncrementGap, Boolean includeInAll, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) { super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo); assert fieldType.tokenized(); assert fieldType.hasDocValues() == false; if (fieldType().indexOptions() == IndexOptions.NONE && fieldType().fielddata()) { throw new IllegalArgumentException("Cannot enable fielddata on a [text] field that is not indexed: [" + name() + "]"); } this.positionIncrementGap = positionIncrementGap; this.includeInAll = includeInAll; }
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { if (indexSettings.getIndexVersionCreated().before(Version.V_2_2_0) && fieldType.hasDocValues() == false) { return new GeoPointArrayIndexFieldData(indexSettings, fieldType.name(), cache, breakerService); } // Ignore breaker return new GeoPointDVIndexFieldData(indexSettings.getIndex(), fieldType.name(), indexSettings.getIndexVersionCreated().before(Version.V_2_2_0)); } }
@Override public void createField(ParseContext context, Object value) throws IOException { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } context.doc().add(new Field(fieldType().name(), context.type(), fieldType())); if (fieldType().hasDocValues()) { context.doc().add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.type()))); } }