Skip to content

Commit

Permalink
When for a stored and indexed preanalyzed field there is no tokenstream,
Browse files Browse the repository at this point in the history
no longer an error is thrown; there just won't be anything to search
for.
  • Loading branch information
khituras committed Feb 4, 2016
1 parent 96b2d09 commit 8b488bb
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,20 @@ protected void parseCreateField(ParseContext context, List<Field> fields) throws
// eventually.
if (fieldType().indexOptions() != IndexOptions.NONE && fieldType().tokenized()) {
TokenStream ts = valueAndTokenStream.v2();
if (null == ts) {
String value = null;
if (valueAndTokenStream
.v1().type == org.elasticsearch.index.mapper.preanalyzed.PreAnalyzedMapper.PreAnalyzedStoredValue.VALUE_TYPE.STRING) {
value = (String) valueAndTokenStream.v1().value;
if (value.length() > 200)
value = value.substring(0, 200);
}
throw new IllegalStateException("The preanalyzed field \"" + fieldType().names().fullName()
+ "\" is tokenized and indexed, but no preanalyzed TokenStream could be found. (id: "
+ context.id() + "; field value: " + value + ")");

} else {
// if (null == ts) {
// String value = null;
// if (valueAndTokenStream
// .v1().type == org.elasticsearch.index.mapper.preanalyzed.PreAnalyzedMapper.PreAnalyzedStoredValue.VALUE_TYPE.STRING) {
// value = (String) valueAndTokenStream.v1().value;
// if (value.length() > 200)
// value = value.substring(0, 200);
// }
// throw new IllegalStateException("The preanalyzed field \"" + fieldType().names().fullName()
// + "\" is tokenized and indexed, but no preanalyzed TokenStream could be found. (id: "
// + context.id() + "; field value: " + value + ")");
//
// } else {
if (ts != null) {
Field field = new Field(fieldTypeIndexed.names().indexName(), ts, fieldTypeIndexed);
fields.add(field);
}
Expand Down

0 comments on commit 8b488bb

Please sign in to comment.