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) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
fieldName = parser.currentName();
|
fieldName = parser.currentName();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ("linear".equals(fieldName)) {
|
if ("linear".equals(fieldName)) {
|
||||||
ensureNoSmoothing(suggestion);
|
ensureNoSmoothing(suggestion);
|
||||||
final double[] lambdas = new double[3];
|
final double[] lambdas = new double[3];
|
||||||
|
@ -186,7 +183,8 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
||||||
throw new ElasticSearchIllegalArgumentException("unigram_lambda must be positive");
|
throw new ElasticSearchIllegalArgumentException("unigram_lambda must be positive");
|
||||||
}
|
}
|
||||||
} else {
|
} 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 + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,9 +216,10 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final double alpha = theAlpha;
|
final double alpha = theAlpha;
|
||||||
suggestion.setModel( new WordScorer.WordScorerFactory() {
|
suggestion.setModel(new WordScorer.WordScorerFactory() {
|
||||||
@Override
|
@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);
|
return new LaplaceScorer(reader, field, realWordLikelyhood, separator, alpha);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -237,9 +236,10 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final double discount = theDiscount;
|
final double discount = theDiscount;
|
||||||
suggestion.setModel( new WordScorer.WordScorerFactory() {
|
suggestion.setModel(new WordScorer.WordScorerFactory() {
|
||||||
@Override
|
@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);
|
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 + "]");
|
throw new ElasticSearchIllegalArgumentException("suggester[phrase] doesn't support object field [" + fieldName + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ensureNoSmoothing(PhraseSuggestionContext suggestion) {
|
private void ensureNoSmoothing(PhraseSuggestionContext suggestion) {
|
||||||
if (suggestion.model() != null) {
|
if (suggestion.model() != null) {
|
||||||
|
|
Loading…
Reference in New Issue