From 1ec1716a7b88134054f31814a48fc1614d583ff2 Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 26 Feb 2010 15:28:38 +0200 Subject: [PATCH] analyzer might end up being null --- .../index/query/json/MoreLikeThisFieldJsonQueryParser.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/json/MoreLikeThisFieldJsonQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/json/MoreLikeThisFieldJsonQueryParser.java index 5fdf8b395dd..a52445ad3b0 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/json/MoreLikeThisFieldJsonQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/json/MoreLikeThisFieldJsonQueryParser.java @@ -114,7 +114,6 @@ public class MoreLikeThisFieldJsonQueryParser extends AbstractIndexComponent imp token = jp.nextToken(); assert token == JsonToken.END_OBJECT; - mltQuery.setAnalyzer(parseContext.mapperService().searchAnalyzer()); MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); if (smartNameFieldMappers != null) { if (smartNameFieldMappers.hasMapper()) { @@ -122,6 +121,9 @@ public class MoreLikeThisFieldJsonQueryParser extends AbstractIndexComponent imp mltQuery.setAnalyzer(smartNameFieldMappers.mapper().searchAnalyzer()); } } + if (mltQuery.getAnalyzer() == null) { + mltQuery.setAnalyzer(parseContext.mapperService().searchAnalyzer()); + } mltQuery.setMoreLikeFields(new String[]{fieldName}); return wrapSmartNameQuery(mltQuery, smartNameFieldMappers, parseContext.filterCache()); }