shahrs87 commented on PR #907:
URL: https://github.com/apache/lucene/pull/907#issuecomment-1183747929
Thank you @jpountz for being so patient with me. I tried your above
suggestion and hit the following problem.
Locally I removed the following check from BloomFilteringPostingsFormat.java.
```
if (result == Terms.EMPTY) {
return Terms.EMPTY;
}
```
The following test failed:
`org.apache.lucene.index.TestPostingsOffsets.testCrazyOffsetGap`
Can be reproduced by:
`gradlew :lucene:core:test --tests
"org.apache.lucene.index.TestPostingsOffsets.testCrazyOffsetGap" -Ptests.jvms=8
-Ptests.jvmargs=-XX:TieredStopAtLevel=1 -Ptests.seed=66D42010A32F9625
-Ptests.locale=chr -Ptests.timezone=Asia/Jayapura -Ptests.gui=false
-Ptests.file.encoding=UTF-8`
The exception stack trace is:
```
field "foo" should have hasFreqs=true but got false
org.apache.lucene.index.CheckIndex$CheckIndexException: field "foo" should
have hasFreqs=true but got false
at
__randomizedtesting.SeedInfo.seed([66D42010A32F9625:91A6069AD047326B]:0)
at
app//org.apache.lucene.index.CheckIndex.checkFields(CheckIndex.java:1434)
at
app//org.apache.lucene.index.CheckIndex.testPostings(CheckIndex.java:2425)
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.index.TestPostingsOffsets.testCrazyOffsetGap(TestPostingsOffsets.java:462)
```
The terms object
[here](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java#L1380)
is of type
[PerFieldPostingsFormat#FieldsReader](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java#L352)
The fieldsProducer object within PerFieldPostingsFormat#FieldsReader is of
type
[BloomFilteringPostingsFormat#BloomFilteredFieldsProducer](https://github.com/apache/lucene/blob/main/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java#L202)
The delegateFieldsProducer within
BloomFilteringPostingsFormat#BloomFilteredFieldsProducer is of type
[Lucene90BlockTreeTermsReader](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java#L291)
This is the code snippet which I changed within
`Lucene90BlockTreeTermsReader#terms` method
```
@Override
public Terms terms(String field) throws IOException {
assert field != null;
Terms terms = fieldMap.get(field);
return terms == null ? Terms.EMPTY : terms;
}
```
From your suggestion instead of returning Terms.EMPTY, I thought to return
Terms.empty(fieldInfo) with overloaded hasFreqs, hasPositions, etc. methods.
But the problem is there is no way to get hold of `FieldsInfo` object from
`field` string. The fieldMap map within Lucene90BlockTreeTermsReader is empty.
Is it ok to change the method argument for terms method from field String to
fieldInfo object within Lucene90BlockTreeTermsReader ? `public Terms
terms(String field) throws IOException` --> `public Terms terms(FieldInfo
fieldInfo) throws IOException` I think NO but just wanted to ask.
Please correct me if I am misunderstanding anything. Thank you again.
--
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]