exhaust object to allow subsequent objects to be parsed correctly
This commit is contained in:
parent
1f217f6a7b
commit
12a2808168
|
@ -159,9 +159,6 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
|||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
fieldName = parser.currentName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ("linear".equals(fieldName)) {
|
||||
ensureNoSmoothing(suggestion);
|
||||
final double[] lambdas = new double[3];
|
||||
|
@ -186,7 +183,8 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
|||
throw new ElasticSearchIllegalArgumentException("unigram_lambda must be positive");
|
||||
}
|
||||
} else {
|
||||
throw new ElasticSearchIllegalArgumentException("suggester[phrase][smoothing][linear] doesn't support field [" + fieldName + "]");
|
||||
throw new ElasticSearchIllegalArgumentException(
|
||||
"suggester[phrase][smoothing][linear] doesn't support field [" + fieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +218,8 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
|||
final double alpha = theAlpha;
|
||||
suggestion.setModel(new WordScorer.WordScorerFactory() {
|
||||
@Override
|
||||
public WordScorer newScorer(IndexReader reader, String field, double realWordLikelyhood, BytesRef separator) throws IOException {
|
||||
public WordScorer newScorer(IndexReader reader, String field, double realWordLikelyhood, BytesRef separator)
|
||||
throws IOException {
|
||||
return new LaplaceScorer(reader, field, realWordLikelyhood, separator, alpha);
|
||||
}
|
||||
});
|
||||
|
@ -239,7 +238,8 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
|||
final double discount = theDiscount;
|
||||
suggestion.setModel(new WordScorer.WordScorerFactory() {
|
||||
@Override
|
||||
public WordScorer newScorer(IndexReader reader, String field, double realWordLikelyhood, BytesRef separator) throws IOException {
|
||||
public WordScorer newScorer(IndexReader reader, String field, double realWordLikelyhood, BytesRef separator)
|
||||
throws IOException {
|
||||
return new StupidBackoffScorer(reader, field, realWordLikelyhood, separator, discount);
|
||||
}
|
||||
});
|
||||
|
@ -248,6 +248,8 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
|||
throw new ElasticSearchIllegalArgumentException("suggester[phrase] doesn't support object field [" + fieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureNoSmoothing(PhraseSuggestionContext suggestion) {
|
||||
if (suggestion.model() != null) {
|
||||
|
|
Loading…
Reference in New Issue