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 _analyzer field #9381

Merged
merged 1 commit into from Jan 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/reference/mapping/fields.asciidoc
Expand Up @@ -15,8 +15,6 @@ include::fields/source-field.asciidoc[]

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

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

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

include::fields/field-names-field.asciidoc[]
Expand Down
41 changes: 0 additions & 41 deletions docs/reference/mapping/fields/analyzer-field.asciidoc

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/org/elasticsearch/index/engine/Engine.java
Expand Up @@ -374,7 +374,7 @@ public List<Document> docs() {
}

public Analyzer analyzer() {
return this.doc.analyzer();
return docMapper.mappers().indexAnalyzer();
}

public BytesReference source() {
Expand Down
40 changes: 29 additions & 11 deletions src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java
Expand Up @@ -22,7 +22,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
Expand All @@ -45,19 +44,43 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.text.StringAndBytesText;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.common.xcontent.smile.SmileXContent;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
import org.elasticsearch.index.mapper.internal.*;
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
import org.elasticsearch.index.mapper.internal.BoostFieldMapper;
import org.elasticsearch.index.mapper.internal.FieldNamesFieldMapper;
import org.elasticsearch.index.mapper.internal.IdFieldMapper;
import org.elasticsearch.index.mapper.internal.IndexFieldMapper;
import org.elasticsearch.index.mapper.internal.ParentFieldMapper;
import org.elasticsearch.index.mapper.internal.RoutingFieldMapper;
import org.elasticsearch.index.mapper.internal.SizeFieldMapper;
import org.elasticsearch.index.mapper.internal.SourceFieldMapper;
import org.elasticsearch.index.mapper.internal.TTLFieldMapper;
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
import org.elasticsearch.index.mapper.internal.TypeFieldMapper;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import org.elasticsearch.index.mapper.internal.VersionFieldMapper;
import org.elasticsearch.index.mapper.object.ObjectMapper;
import org.elasticsearch.index.mapper.object.RootObjectMapper;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptService.ScriptType;

import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

import static com.google.common.collect.Lists.newArrayList;
Expand Down Expand Up @@ -184,7 +207,6 @@ public Builder(String index, Settings indexSettings, RootObjectMapper.Builder bu
this.rootMappers.put(IndexFieldMapper.class, new IndexFieldMapper());
this.rootMappers.put(SourceFieldMapper.class, new SourceFieldMapper(indexSettings));
this.rootMappers.put(TypeFieldMapper.class, new TypeFieldMapper());
this.rootMappers.put(AnalyzerMapper.class, new AnalyzerMapper());
this.rootMappers.put(AllFieldMapper.class, new AllFieldMapper());
this.rootMappers.put(BoostFieldMapper.class, new BoostFieldMapper(indexSettings));
this.rootMappers.put(TimestampFieldMapper.class, new TimestampFieldMapper(indexSettings));
Expand Down Expand Up @@ -408,10 +430,6 @@ public SourceFieldMapper sourceMapper() {
return rootMapper(SourceFieldMapper.class);
}

public AnalyzerMapper analyzerMapper() {
return rootMapper(AnalyzerMapper.class);
}

public AllFieldMapper allFieldMapper() {
return rootMapper(AllFieldMapper.class);
}
Expand Down Expand Up @@ -578,7 +596,7 @@ public ParsedDocument parse(SourceToParse source, @Nullable ParseListener listen
}
}

ParsedDocument doc = new ParsedDocument(context.uid(), context.version(), context.id(), context.type(), source.routing(), source.timestamp(), source.ttl(), context.docs(), context.analyzer(),
ParsedDocument doc = new ParsedDocument(context.uid(), context.version(), context.id(), context.type(), source.routing(), source.timestamp(), source.ttl(), context.docs(),
context.source(), context.mappingsModified()).parent(source.parent());
// reset the context to free up memory
context.reset(null, null, null, null);
Expand Down
Expand Up @@ -56,7 +56,6 @@
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
import org.elasticsearch.index.mapper.internal.AnalyzerMapper;
import org.elasticsearch.index.mapper.internal.BoostFieldMapper;
import org.elasticsearch.index.mapper.internal.FieldNamesFieldMapper;
import org.elasticsearch.index.mapper.internal.IdFieldMapper;
Expand Down Expand Up @@ -147,7 +146,6 @@ public DocumentMapperParser(Index index, @IndexSettings Settings indexSettings,
.put(SourceFieldMapper.NAME, new SourceFieldMapper.TypeParser())
.put(TypeFieldMapper.NAME, new TypeFieldMapper.TypeParser())
.put(AllFieldMapper.NAME, new AllFieldMapper.TypeParser())
.put(AnalyzerMapper.NAME, new AnalyzerMapper.TypeParser())
.put(BoostFieldMapper.NAME, new BoostFieldMapper.TypeParser())
.put(ParentFieldMapper.NAME, new ParentFieldMapper.TypeParser())
.put(RoutingFieldMapper.NAME, new RoutingFieldMapper.TypeParser())
Expand Down
Expand Up @@ -97,10 +97,6 @@ public static AllFieldMapper.Builder all() {
return new AllFieldMapper.Builder();
}

public static AnalyzerMapper.Builder analyzer() {
return new AnalyzerMapper.Builder();
}

public static RootObjectMapper.Builder rootObject(String name) {
return new RootObjectMapper.Builder(name);
}
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/org/elasticsearch/index/mapper/ParseContext.java
Expand Up @@ -354,16 +354,6 @@ public AllEntries allEntries() {
return in.allEntries();
}

@Override
public Analyzer analyzer() {
return in.analyzer();
}

@Override
public void analyzer(Analyzer analyzer) {
in.analyzer(analyzer);
}

@Override
public boolean externalValueSet() {
return in.externalValueSet();
Expand Down Expand Up @@ -405,8 +395,6 @@ public static class InternalParseContext extends ParseContext {

private List<Document> documents = Lists.newArrayList();

private Analyzer analyzer;

private final String index;

@Nullable
Expand Down Expand Up @@ -449,7 +437,6 @@ public void reset(XContentParser parser, Document document, SourceToParse source
} else {
this.documents = null;
}
this.analyzer = null;
this.uid = null;
this.version = null;
this.id = null;
Expand Down Expand Up @@ -600,14 +587,6 @@ public AllEntries allEntries() {
return this.allEntries;
}

public Analyzer analyzer() {
return this.analyzer;
}

public void analyzer(Analyzer analyzer) {
this.analyzer = analyzer;
}

public float docBoost() {
return this.docBoost;
}
Expand Down Expand Up @@ -789,10 +768,6 @@ private boolean includeInAll(Boolean specificIncludeInAll, boolean indexed) {

public abstract AllEntries allEntries();

public abstract Analyzer analyzer();

public abstract void analyzer(Analyzer analyzer);

/**
* Return a new context that will have the external value set.
*/
Expand Down
Expand Up @@ -46,15 +46,13 @@ public class ParsedDocument {

private final List<Document> documents;

private final Analyzer analyzer;

private BytesReference source;

private boolean mappingsModified;

private String parent;

public ParsedDocument(Field uid, Field version, String id, String type, String routing, long timestamp, long ttl, List<Document> documents, Analyzer analyzer, BytesReference source, boolean mappingsModified) {
public ParsedDocument(Field uid, Field version, String id, String type, String routing, long timestamp, long ttl, List<Document> documents, BytesReference source, boolean mappingsModified) {
this.uid = uid;
this.version = version;
this.id = id;
Expand All @@ -64,7 +62,6 @@ public ParsedDocument(Field uid, Field version, String id, String type, String r
this.ttl = ttl;
this.documents = documents;
this.source = source;
this.analyzer = analyzer;
this.mappingsModified = mappingsModified;
}

Expand Down Expand Up @@ -104,10 +101,6 @@ public List<Document> docs() {
return this.documents;
}

public Analyzer analyzer() {
return this.analyzer;
}

public BytesReference source() {
return this.source;
}
Expand Down
Expand Up @@ -236,13 +236,10 @@ protected void parseCreateField(ParseContext context, List<Field> fields) throws
private Analyzer findAnalyzer(ParseContext context) {
Analyzer analyzer = indexAnalyzer;
if (analyzer == null) {
analyzer = context.analyzer();
analyzer = context.docMapper().mappers().indexAnalyzer();
if (analyzer == null) {
analyzer = context.docMapper().indexAnalyzer();
if (analyzer == null) {
// This should not happen, should we log warn it?
analyzer = Lucene.STANDARD_ANALYZER;
}
// This should not happen, should we log warn it?
analyzer = Lucene.STANDARD_ANALYZER;
}
}
return analyzer;
Expand Down