shahrs87 commented on code in PR #907:
URL: https://github.com/apache/lucene/pull/907#discussion_r905458119
##########
lucene/core/src/java/org/apache/lucene/index/CheckIndex.java:
##########
@@ -1378,7 +1378,7 @@ private static Status.TermIndexStatus checkFields(
computedFieldCount++;
final Terms terms = fields.terms(field);
- if (terms == null) {
+ if (terms == Terms.EMPTY) {
Review Comment:
I tried to remove this if (terms == Terms.EMPTY) statement but many tests
failed.
Example of failing test:
`org.apache.lucene.codecs.lucene90.TestLucene90NormsFormat#testUndeadNorms`
Stack trace:
```
> Task :lucene:core:test FAILED
WARNING: A command line option has enabled the Security Manager
WARNING: The Security Manager is deprecated and will be removed in a future
release
org.apache.lucene.codecs.lucene90.TestLucene90NormsFormat > testUndeadNorms
FAILED
org.apache.lucene.index.CheckIndex$CheckIndexException: field "content"
should have hasFreqs=true but got false
at
__randomizedtesting.SeedInfo.seed([2A7308C15B316422:27A64CAC8EDF759E]:0)
at
app//org.apache.lucene.index.CheckIndex.checkFields(CheckIndex.java:1437)
at
app//org.apache.lucene.index.CheckIndex.testPostings(CheckIndex.java:2428)
at
app//org.apache.lucene.index.CheckIndex.testSegment(CheckIndex.java:999)
at
app//org.apache.lucene.index.CheckIndex.checkIndex(CheckIndex.java:714)
at
app//org.apache.lucene.index.CheckIndex.checkIndex(CheckIndex.java:552)
at
app//org.apache.lucene.tests.util.TestUtil.checkIndex(TestUtil.java:343)
at
app//org.apache.lucene.tests.store.MockDirectoryWrapper.close(MockDirectoryWrapper.java:909)
at
app//org.apache.lucene.tests.index.BaseNormsFormatTestCase.testUndeadNorms(BaseNormsFormatTestCase.java:698)
at
[email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
[email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
[email protected]/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:568)
at
app//com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1754)
at
app//com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:942)
at
app//com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:978)
at
app//com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:992)
at
app//org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:44)
at
app//org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
at
app//org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
at
app//org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
at
app//org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
at app//org.junit.rules.RunRules.evaluate(RunRules.java:20)
```
I think the problem is:
Even though the `content` field is deleted, it is still present in fields
returned by `reader#getPostingsReader`
[here](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java#L2417)
Since the returned terms is EMPTY it has `hasFreqs` set to `false` but since
this field exists in fields and the indexOptions set to
`DOCS_AND_FREQS_AND_POSITIONS` it is expecting hasFreqs to true.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]