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

semantic_text: Add index metadata information for inference field mappers #107147

Conversation

carlosdelest
Copy link
Member

As prior work for semantic_text new field type, these changes add new IndexMetadata information for field types that need inference to be performed.

As inference is done in the coordinator node to avoid re-doing it at shard / replica level, the coordinator needs to check for the need to perform inference for specific fields in an index.

Given that the coordinator node does not necessarily have mapping information for all indices (only for those that have shards in the node), the field inference information must be stored in the IndexMetadata and broadcasted to all nodes.

This change adds:

  • An InferenceFieldMetadata class that contains the information for fields that need inference
    • A new InferenceFieldMapper interface that will be implemented by semantic_text and any other field types that require inference, so this information can be retrieved from the field mapping
  • Changes to the mapping lookup and mapping service creation to include this information from the mapping into the IndexMetadata

@carlosdelest carlosdelest changed the title semantic_text: Add cluster metadata information for inference field mappers semantic_text: Add index metadata information for inference field mappers Apr 5, 2024
@carlosdelest carlosdelest requested review from jimczi and Mikep86 April 5, 2024 10:28
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

Few minor comments, LGTM otherwise. Let's remove the draft status and have another reviewer since the targeted branch is main?

@carlosdelest carlosdelest added >non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team labels Apr 5, 2024
@carlosdelest carlosdelest marked this pull request as ready for review April 5, 2024 12:26
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

A minor concern. I think it all looks OK. My other concerns were about null being accidentally provided in the ctor as we have a ton of stuff that relies on the inference fields not being null, but instead empty, but it seems like we have adequate coverage and protection there. Just being paranoid :)

String inferenceId = randomIdentifier();
String[] inputFields = generateRandomStringArray(5, 10, false, false);
return new InferenceFieldMetadata(name, inferenceId, inputFields);
}
Copy link
Member

Choose a reason for hiding this comment

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

Could we have some tests covering the null cases that throw?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure! dc46e88

@carlosdelest
Copy link
Member Author

@elasticsearchmachine update branch

Copy link
Contributor

@Mikep86 Mikep86 left a comment

Choose a reason for hiding this comment

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

LGTM, only two small qeustions/comments

Copy link
Member

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

LGTM couldn't come up with anything else either as discussed on Slack :) Thanks Carlos!

…metadata-changes

# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
@carlosdelest carlosdelest merged commit c57dd98 into elastic:main Apr 10, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v8.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants