Skip to content
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

Reduce the number of calls to document() from LeafStoredFieldsLookup #66928

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

romseygeek
Copy link
Contributor

LeafStoredFieldsLookup currently uses a SingleFieldsVisitor to load values, which
will be inefficient if a script references more than one stored field. This commit
refactors the lookup to remember all the fields that are requested, along with the
ability to pre-register fields so that the first lookup will also only read from disk
once.

Relates to #66256

@romseygeek romseygeek added :Search/Search Search-related issues that do not fall into other categories >refactoring v8.0.0 v7.12.0 labels Jan 4, 2021
@romseygeek romseygeek self-assigned this Jan 4, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jan 4, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@romseygeek
Copy link
Contributor Author

The idea here is that in future SourceLookup can depend on LeafStoredFieldsLookup to load its values, allowing us to consolidate loading source and stored fields together in a single place rather than spread across the Fetch phase.

@jtibshirani
Copy link
Contributor

jtibshirani commented Jan 4, 2021

I still need to ponder the refactor in detail, but had some initial thoughts.

LeafStoredFieldsLookup currently uses a SingleFieldsVisitor to load values, which will be inefficient if a script references more than one stored field.

It's rare for scripts to access stored fields, and in general we hope to decrease reliance on stored fields (maybe eventually deprecating them?) So this refactor doesn't feel high priority in itself. However you mention that this is an incremental step towards having SourceLookup use a shared stored fields visitor. I don't yet see how this would work -- would you be able to describe the plan in more detail (or even show a quick prototype if you've tried it out?)

The idea here is that in future SourceLookup can depend on LeafStoredFieldsLookup to load its values,

I see these Leaf*Lookup classes as specifically designed for scripting. They make sure to implement Map<String, Object>, sometimes add an extra caching layer, etc. I wonder if we should keep script data structures separate from the general lookup case for flexibility/ clarity. The fact that SourceLookup is used in both cases has actually caused complexity, see this comment for example.

@mark-vieira
Copy link
Contributor

@elasticmachine update branch

@anupamgogoi0907
Copy link

Hi Team,
Is the issue solved? I don't see any further comments.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>refactoring :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet