-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add SegmentOrder utility class for per-query segment re-ordering #15591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This allows client code that is querying sorted indexes to ensure that segments most likely to produce entries in a top-k search are queried first, allowing efficient skipping of other segments.
|
|
||
| @Override | ||
| public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { | ||
| String segmentId = context.toString().substring(19, 20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something of a hack, but I couldn't think of an easier way to work out what the 'original' ordinal for a segment is. Less hacky solution ideas are welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't ord a public field in LeafReaderContext?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, but it is generated by BaseCompositeReader after the segment sorter has been applied. So the ord of the first segment in the leaves array is always 0, and we can't use it to see if the segments have been re-ordered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, segment id - nevermind. Don't know. The substring hack seems... very fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the test to just compare the order of leaves before and after the re-ordering. The collector checks were necessary when I was wiring everything through IndexSearcher but aren't needed now.
…che#15591) This allows client code that is querying sorted indexes to ensure that segments most likely to produce entries in a top-k search are queried first, allowing efficient skipping of other segments.
This allows client code that is querying sorted indexes to ensure that segments most likely to produce entries in a top-k search are queried first, allowing efficient skipping of other segments.