Use dummy TermStatistics when term is not found Closes #10660
This commit is contained in:
parent
069e11ba40
commit
a6c154aa7a
|
@ -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) {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue