Skip to content

Conversation

@bzhangam
Copy link
Owner

@bzhangam bzhangam commented Mar 19, 2025

Description

Add semantic mapping transformer to transform mapping for semantic fields.

It will auto add semantic info fields to the mapping based on the model id defined in the semantic fields.

Note

This PR is based on this one. And it's not target the main branch of the neural plugin main. It's just for review purpose.

Related Issues

#[803] - Proposal to support semantic field in neural search.
#[1211] - HLD of the semantic field.

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@bzhangam bzhangam force-pushed the semanticMappingTransformer branch from e0530c8 to 8e36a35 Compare March 19, 2025 20:29
@Override
public void onResponse(MLModel mlModel) {
try {
modifyMappings(mappings, mlModel, modelIdToFieldPathMap.get(modelId), semanticFieldPathToConfigMap, modelId);
Copy link

Choose a reason for hiding this comment

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

Any multithreading concerns here with modifying a map like this if the map isn't a ConcurrentHashMap/SkipListMap? I An alternative thread-safe way could be to use PlainActionListeners to await the model info with blocking and then modify the mappings synchronously

Copy link
Owner Author

Choose a reason for hiding this comment

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

Should be no risk since we don't iterate the map here. But to make it safe I can add synchronized to ensure we modify the mapping synchronously. Since we don't expect too many model ids in one mapping and modifying the map is a fast local calculation we should be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants