Skip to content

Commit

Permalink
Setting index_analyzer incorrectly sets analyzer
Browse files Browse the repository at this point in the history
fixes #2329
  • Loading branch information
kimchy committed Oct 16, 2012
1 parent c2073c3 commit a963bc1
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public abstract static class Builder<T extends Builder, Y extends AbstractFieldM
protected float boost = Defaults.BOOST;

protected boolean omitNorms = Defaults.OMIT_NORMS;

protected String indexName;

protected NamedAnalyzer indexAnalyzer;
Expand Down Expand Up @@ -154,22 +154,19 @@ protected T omitNorms(boolean omitNorms) {
this.omitNorms = omitNorms;
return builder;
}

protected T indexOptions(IndexOptions indexOptions) {
this.indexOptions = indexOptions;
return builder;
}

protected T indexName(String indexName) {
this.indexName = indexName;
return builder;
}

protected T indexAnalyzer(NamedAnalyzer indexAnalyzer) {
this.indexAnalyzer = indexAnalyzer;
if (this.searchAnalyzer == null) {
this.searchAnalyzer = indexAnalyzer;
}
return builder;
}

Expand Down Expand Up @@ -208,7 +205,7 @@ protected String buildFullName(BuilderContext context) {
protected float boost;

protected final boolean omitNorms;

protected final FieldInfo.IndexOptions indexOptions;

protected final NamedAnalyzer indexAnalyzer;
Expand All @@ -224,7 +221,7 @@ protected AbstractFieldMapper(Names names, Field.Index index, Field.Store store,
this.boost = boost;
this.omitNorms = omitNorms;
this.indexOptions = indexOptions;

// automatically set to keyword analyzer if its indexed and not analyzed
if (indexAnalyzer == null && !index.isAnalyzed() && index.isIndexed()) {
this.indexAnalyzer = Lucene.KEYWORD_ANALYZER;
Expand Down Expand Up @@ -288,7 +285,7 @@ public float boost() {
public boolean omitNorms() {
return this.omitNorms;
}

@Override
public IndexOptions indexOptions() {
return this.indexOptions;
Expand Down Expand Up @@ -480,17 +477,17 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.endObject();
return builder;
}

protected static String indexOptionToString(IndexOptions indexOption) {
switch (indexOption) {
case DOCS_AND_FREQS:
return TypeParsers.INDEX_OPTIONS_FREQS;
case DOCS_AND_FREQS_AND_POSITIONS:
return TypeParsers.INDEX_OPTIONS_POSITIONS;
case DOCS_ONLY:
return TypeParsers.INDEX_OPTIONS_DOCS;
default:
throw new ElasticSearchIllegalArgumentException("Unknown IndexOptions [" + indexOption + "]");
case DOCS_AND_FREQS:
return TypeParsers.INDEX_OPTIONS_FREQS;
case DOCS_AND_FREQS_AND_POSITIONS:
return TypeParsers.INDEX_OPTIONS_POSITIONS;
case DOCS_ONLY:
return TypeParsers.INDEX_OPTIONS_DOCS;
default:
throw new ElasticSearchIllegalArgumentException("Unknown IndexOptions [" + indexOption + "]");
}
}

Expand Down

0 comments on commit a963bc1

Please sign in to comment.