Use dummy TermStatistics when term is not found Closes #10660

This commit is contained in:
Simon Willnauer 2015-04-20 11:46:29 +02:00
parent 069e11ba40
commit a6c154aa7a
2 changed files with 8 additions and 3 deletions

View File

@ -104,9 +104,14 @@ final class TermVectorsWriter {
if (flags.contains(Flag.TermStatistics)) {
// get the doc frequency
if (dfs != null) {
writeTermStatistics(dfs.termStatistics().get(term));
final TermStatistics statistics = dfs.termStatistics().get(term);
writeTermStatistics(statistics == null ? new TermStatistics(termBytesRef, 0, 0) : statistics);
} else {
writeTermStatistics(topLevelIterator);
if (foundTerm) {
writeTermStatistics(topLevelIterator);
} else {
writeTermStatistics(new TermStatistics(termBytesRef, 0, 0));
}
}
}
if (useDocsAndPos) {

View File

@ -875,7 +875,7 @@ public class GetTermVectorsTests extends AbstractTermVectorsTests {
checkBrownFoxTermVector(resp.getFields(), "field1", false);
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/10660")
@Test
public void testArtificialNonExistingField() throws Exception {
// setup indices
ImmutableSettings.Builder settings = settingsBuilder()