Setting index_analyzer incorrectly sets analyzer

fixes #2329
This commit is contained in:
Shay Banon 2012-10-16 09:19:47 -04:00
parent c2073c343d
commit a963bc1dc9
1 changed files with 15 additions and 18 deletions

View File

@ -115,7 +115,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
protected float boost = Defaults.BOOST; protected float boost = Defaults.BOOST;
protected boolean omitNorms = Defaults.OMIT_NORMS; protected boolean omitNorms = Defaults.OMIT_NORMS;
protected String indexName; protected String indexName;
protected NamedAnalyzer indexAnalyzer; protected NamedAnalyzer indexAnalyzer;
@ -154,12 +154,12 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
this.omitNorms = omitNorms; this.omitNorms = omitNorms;
return builder; return builder;
} }
protected T indexOptions(IndexOptions indexOptions) { protected T indexOptions(IndexOptions indexOptions) {
this.indexOptions = indexOptions; this.indexOptions = indexOptions;
return builder; return builder;
} }
protected T indexName(String indexName) { protected T indexName(String indexName) {
this.indexName = indexName; this.indexName = indexName;
return builder; return builder;
@ -167,9 +167,6 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
protected T indexAnalyzer(NamedAnalyzer indexAnalyzer) { protected T indexAnalyzer(NamedAnalyzer indexAnalyzer) {
this.indexAnalyzer = indexAnalyzer; this.indexAnalyzer = indexAnalyzer;
if (this.searchAnalyzer == null) {
this.searchAnalyzer = indexAnalyzer;
}
return builder; return builder;
} }
@ -208,7 +205,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
protected float boost; protected float boost;
protected final boolean omitNorms; protected final boolean omitNorms;
protected final FieldInfo.IndexOptions indexOptions; protected final FieldInfo.IndexOptions indexOptions;
protected final NamedAnalyzer indexAnalyzer; protected final NamedAnalyzer indexAnalyzer;
@ -224,7 +221,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
this.boost = boost; this.boost = boost;
this.omitNorms = omitNorms; this.omitNorms = omitNorms;
this.indexOptions = indexOptions; this.indexOptions = indexOptions;
// automatically set to keyword analyzer if its indexed and not analyzed // automatically set to keyword analyzer if its indexed and not analyzed
if (indexAnalyzer == null && !index.isAnalyzed() && index.isIndexed()) { if (indexAnalyzer == null && !index.isAnalyzed() && index.isIndexed()) {
this.indexAnalyzer = Lucene.KEYWORD_ANALYZER; this.indexAnalyzer = Lucene.KEYWORD_ANALYZER;
@ -288,7 +285,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
public boolean omitNorms() { public boolean omitNorms() {
return this.omitNorms; return this.omitNorms;
} }
@Override @Override
public IndexOptions indexOptions() { public IndexOptions indexOptions() {
return this.indexOptions; return this.indexOptions;
@ -480,17 +477,17 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
builder.endObject(); builder.endObject();
return builder; return builder;
} }
protected static String indexOptionToString(IndexOptions indexOption) { protected static String indexOptionToString(IndexOptions indexOption) {
switch (indexOption) { switch (indexOption) {
case DOCS_AND_FREQS: case DOCS_AND_FREQS:
return TypeParsers.INDEX_OPTIONS_FREQS; return TypeParsers.INDEX_OPTIONS_FREQS;
case DOCS_AND_FREQS_AND_POSITIONS: case DOCS_AND_FREQS_AND_POSITIONS:
return TypeParsers.INDEX_OPTIONS_POSITIONS; return TypeParsers.INDEX_OPTIONS_POSITIONS;
case DOCS_ONLY: case DOCS_ONLY:
return TypeParsers.INDEX_OPTIONS_DOCS; return TypeParsers.INDEX_OPTIONS_DOCS;
default: default:
throw new ElasticSearchIllegalArgumentException("Unknown IndexOptions [" + indexOption + "]"); throw new ElasticSearchIllegalArgumentException("Unknown IndexOptions [" + indexOption + "]");
} }
} }