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

Add index-time scripts to IP field mapper #71617

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

romseygeek
Copy link
Contributor

This commit allows you to set 'script' and 'on_script_error' parameters
on IP field mappers, meaning that runtime IP fields can be made indexed
simply by moving their definitions from the runtime section of the mappings
to the properties section.

@romseygeek romseygeek added >feature :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 v7.13.0 labels Apr 13, 2021
@romseygeek romseygeek self-assigned this Apr 13, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Apr 13, 2021
@elasticmachine
Copy link
Collaborator

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

@romseygeek romseygeek requested a review from javanna April 13, 2021 10:05
public final void runForDoc(int docId, Consumer<InetAddress> consumer) {
runForDoc(docId);
for (int i = 0; i < count; i++) {
consumer.accept(InetAddressPoint.decode(values[i].bytes));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Annoyingly, emit takes an InetAddress and encodes it into a BytesRef and this then immediately decodes it back to an InetAddress to pass to the indexer. Possibly as a follow up it might be worth changing the script to store its values as InetAddresses and to decode them for doc values access only?

Copy link
Member

Choose a reason for hiding this comment

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

makes sense to me

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM

public final void runForDoc(int docId, Consumer<InetAddress> consumer) {
runForDoc(docId);
for (int i = 0; i < count; i++) {
consumer.accept(InetAddressPoint.decode(values[i].bytes));
Copy link
Member

Choose a reason for hiding this comment

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

makes sense to me

* @param context the search execution context
* @return the value fetcher
*/
static ValueFetcher valueFetcher(FieldValues<?> fieldValues, Function<Object, Object> formatter, SearchExecutionContext context) {
Copy link
Member

Choose a reason for hiding this comment

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

the plan is to reuse this for dates too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly

@romseygeek romseygeek merged commit 67db253 into elastic:master Apr 13, 2021
@romseygeek romseygeek deleted the mapper/ip-index-script branch April 13, 2021 12:40
romseygeek added a commit that referenced this pull request Apr 13, 2021
This commit allows you to set 'script' and 'on_script_error' parameters
on IP field mappers, meaning that runtime IP fields can be made indexed
simply by moving their definitions from the runtime section of the mappings
to the properties section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>feature :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.13.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants