Deepika0510 commented on code in PR #12345:
URL: https://github.com/apache/lucene/pull/12345#discussion_r1257492761
##########
lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java:
##########
@@ -763,6 +763,11 @@ public Query rewrite(Query original) throws IOException {
for (Query rewrittenQuery = query.rewrite(this);
rewrittenQuery != query;
rewrittenQuery = query.rewrite(this)) {
+ if (queryTimeout != null) {
Review Comment:
Thank you @mikemccand and @jpountz for suggestion!
I was going through the code and came across the below scenario. We want to
wrap terms and points, but the related methods are in `LeafReader` class and we
access these method generally using the
`getContext().leaves().get(0).reader().<method>`.
E.g.
```
IndexReaderContext topReaderContext = reader.getContext();
for (LeafReaderContext context : topReaderContext.leaves()) {
final Terms terms = context.reader().terms(query.field);
……
……
……
}
```
So, even if we wrap `LeafReader` and update `IndexSearcher#getIndexReader()`
to return the wrapped reader, we would not be able to return wrapped class at
such above point where we get the reader using `ReaderContext` .
Maybe one way out would be to create a separate `ReaderContext` such that it
returns our wrapped `IndexReader`?
##########
lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java:
##########
@@ -763,6 +763,11 @@ public Query rewrite(Query original) throws IOException {
for (Query rewrittenQuery = query.rewrite(this);
rewrittenQuery != query;
rewrittenQuery = query.rewrite(this)) {
+ if (queryTimeout != null) {
Review Comment:
Thank you @mikemccand and @jpountz for suggestion!
I was going through the code and came across the below scenario. We want to
wrap terms and points, but the related methods are in `LeafReader` class and we
access these method generally using the
`getContext().leaves().get(0).reader().<method>`.
E.g.
```
IndexReaderContext topReaderContext = reader.getContext();
for (LeafReaderContext context : topReaderContext.leaves()) {
final Terms terms = context.reader().terms(query.field);
……
……
……
}
```
So, even if we wrap `LeafReader` and update `IndexSearcher#getIndexReader()`
to return the wrapped reader, we would not be able to return wrapped class at
such above point where we get the reader using `ReaderContext` .
Maybe one way out would be to create a separate `ReaderContext` such that it
returns our wrapped `IndexReader`?
--
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]