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

Scripted keyword field #58939

Conversation

javanna
Copy link
Member

@javanna javanna commented Jul 2, 2020

This is the first draft implementation of scripted field of type keyword. Still lots of TODOs to address, this PR targets a feature branch.

Relates to #59332

@javanna javanna added the :Search/Search Search-related issues that do not fall into other categories label Jul 2, 2020
@javanna javanna requested a review from nik9000 July 2, 2020 16:13
@javanna javanna changed the title Runtime keyword field Scripted keyword field Jul 2, 2020
Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, TODOs and al.

private final LeafReaderContext ctx;
private final SourceLookup source;
private final LeafDocLookup fieldData;
private final LeafSearchLookup leafSearchLookup;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok with me.

public AbstractScriptFieldScript(Map<String, Object> params, SourceLookup source, DocLookup fieldData, LeafReaderContext ctx) {
public AbstractScriptFieldScript(Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
this.leafSearchLookup = searchLookup.getLeafSearchLookup(ctx);
//TODO how do other scripts get stored fields exposed? Through asMap? I don't see any getters for them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they have them exposed in weird ways that I don't feel comfortable copying. I'd prefer to make a getter for them.

IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<RepositoriesService> repositoriesServiceSupplier) {
//looks like createComponents gets called after getMappers
this.scriptTypeParser.setScriptService(scriptService);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is kind of nasty. Not a blocker for the PR, and maybe not a blocker ever, but a little sad!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea this caught me by surprise. Though it was not hard to work around.

return null;
}
// keywords are internally stored as utf8 bytes
BytesRef binaryValue = (BytesRef) value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our keywords come out as strings though, right? When does this get called?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea, this is copied from the keyword field....


@Override
protected void parseCreateField(ParseContext context) {
//there is no field!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This'll get called if the source contains the field. I wonder if we should do anything about that? Like, not now, but maybe sometime? I dunno.

@javanna javanna marked this pull request as ready for review July 2, 2020 18:36
@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jul 2, 2020
@javanna javanna merged commit e833e8e into elastic:feature/runtime_fields Jul 2, 2020
@javanna
Copy link
Member Author

javanna commented Jul 2, 2020

@romseygeek given all you are doing with mappings, would you like to have a look too and give us some feedback?

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

Successfully merging this pull request may close these issues.

3 participants