Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TypeFieldMapper #53611

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions docs/reference/mapping/fields.asciidoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[[mapping-fields]]
== Meta-Fields

Each document has metadata associated with it, such as the `_index`, mapping
<<mapping-type-field,`_type`>>, and `_id` meta-fields. The behaviour of some of these meta-fields
Each document has metadata associated with it, such as the `_index` and `_id` meta-fields. The behaviour of some of these meta-fields
can be customised when a mapping type is created.

[float]
Expand All @@ -13,10 +12,6 @@ can be customised when a mapping type is created.

The index to which the document belongs.

<<mapping-type-field,`_type`>>::

The document's <<mapping-type,mapping type>>.

<<mapping-id-field,`_id`>>::

The document's ID.
Expand Down Expand Up @@ -74,5 +69,3 @@ include::fields/routing-field.asciidoc[]

include::fields/source-field.asciidoc[]

include::fields/type-field.asciidoc[]

66 changes: 0 additions & 66 deletions docs/reference/mapping/fields/type-field.asciidoc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public DocumentMapper(MapperService mapperService, Mapping mapping) {
}

final Collection<String> deleteTombstoneMetadataFields = Arrays.asList(VersionFieldMapper.NAME, IdFieldMapper.NAME,
TypeFieldMapper.NAME, SeqNoFieldMapper.NAME, SeqNoFieldMapper.PRIMARY_TERM_NAME, SeqNoFieldMapper.TOMBSTONE_NAME);
SeqNoFieldMapper.NAME, SeqNoFieldMapper.PRIMARY_TERM_NAME, SeqNoFieldMapper.TOMBSTONE_NAME);
this.deleteTombstoneMetadataFieldMappers = Stream.of(mapping.metadataMappers)
.filter(field -> deleteTombstoneMetadataFields.contains(field.name())).toArray(MetadataFieldMapper[]::new);
final Collection<String> noopTombstoneMetadataFields = Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,6 @@ public static Term extractTerm(Query termQuery) {
while (termQuery instanceof BoostQuery) {
termQuery = ((BoostQuery) termQuery).getQuery();
}
if (termQuery instanceof TypeFieldMapper.TypesQuery) {
assert ((TypeFieldMapper.TypesQuery) termQuery).getTerms().length == 1;
return new Term(TypeFieldMapper.NAME, ((TypeFieldMapper.TypesQuery) termQuery).getTerms()[0]);
}
if (termQuery instanceof TermInSetQuery) {
TermInSetQuery tisQuery = (TermInSetQuery) termQuery;
PrefixCodedTerms terms = tisQuery.getTermData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.index.mapper;

import com.carrotsearch.hppc.ObjectHashSet;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
Expand All @@ -28,6 +29,7 @@
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
Expand Down Expand Up @@ -74,6 +76,11 @@

public class MapperService extends AbstractIndexComponent implements Closeable {

private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(QueryShardContext.class));
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using the _type field " +
"in queries and aggregations is deprecated, prefer to use a field instead.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If this is only applicable for v7 compatibility mode, should we cal this constant: TYPES_DEPRECATION_MESSAGE_V7?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove _type field from SORTED_META_FIELDS constant?


/**
* The reason why a mapping is being merged.
*/
Expand Down Expand Up @@ -587,6 +594,11 @@ public DocumentMapperForType documentMapperWithAutoCreate() {
* Given the full name of a field, returns its {@link MappedFieldType}.
*/
public MappedFieldType fieldType(String fullName) {
// TODO wrap this with v7 compatibility
if (fullName.equals(TypeFieldType.NAME)) {
deprecationLogger.deprecatedAndMaybeLog("query_with_types", TYPES_DEPRECATION_MESSAGE);
return TypeFieldType.INSTANCE;
}
return fieldTypes.get(fullName);
}

Expand Down
Loading