-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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 type: update family type and test field caps output #59672
Scripted keyword field type: update family type and test field caps output #59672
Conversation
Pinging @elastic/es-search (:Search/Search) |
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.
LGTM. Probably worth a simple yml test for the field caps too.
I already have a single node integration test, I am not sure that a yaml test adds value at this point. Field caps is already tested separately and we only want to make sure that its output is the same for a runtime field compared to an ordinary field. I can imagine that we may want to revisit this once we change the response format of field caps for runtime fields. |
run elasticsearch-ci/packaging-sample-windows |
@Override | ||
public ScriptBinaryFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { | ||
assert fullyQualifiedIndexName.length() > 0 : "index name must not be empty"; |
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 think that I will remove this assertion. I initially assumed that calling this would make us load doc_values for a runtime field which is expensive, but it will only make us instantiate the classes and doc_values will not be advanced, hence no script is going to be executed.
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.
👍
…s_test_field_caps
…s_test_field_caps
…s_test_field_caps
StringScriptFieldScript.Factory factory = scriptCompiler.compile(script.getValue(), StringScriptFieldScript.CONTEXT); | ||
mappedFieldType = new RuntimeKeywordMappedFieldType(buildFullName(context), script.getValue(), factory, meta.getValue()); | ||
} else { | ||
BiFunction<Builder, BuilderContext, MappedFieldType> fieldTypeResolver = Builder.FIELD_TYPE_RESOLVER.get( |
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.
@nik9000 you may have opinions on this. I added it because I did not want to have tests to maintain a list of supported runtime types and rather rely on the truth which cannot get outdated. Downside is we have no if but rather a map with a bifunction, maybe a bit cryptic.
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'm pretty used to maps to functions at this point. I'm happy with this. I'm not 100% this is better than the switch
statement that I had in #59721, but it does the job just as well. If you like it, I'm happy with it.
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 does not do a better job than the switch, but it allows to expose all the keys for testing :)
Relates to #59332