ai-cfia / azure-db

Operations related to semantic search on our Azure document index.
MIT License
0 stars 1 forks source link

Implement Dynamic Field Mapping in azure-ai-search Package in azure-db #7

Closed k-allagbe closed 8 months ago

k-allagbe commented 9 months ago

In the azure-ai-search package, the current field mapping between Azure AI Search index results and the frontend data is hardcoded. This inflexibility poses challenges in adapting to changes in the index structure without altering the code.

Tasks:

Acceptance Criteria:

rngadam commented 8 months ago

@k-allagbe please report on which off the shelf library you've evaluated to do nested to nested object mapping.

Is it possible, for example, to achieve the same result with pydantic?

https://stackoverflow.com/questions/71574543/how-to-transform-data-for-pydantic-models

k-allagbe commented 8 months ago

@k-allagbe please report on which off the shelf library you've evaluated to do nested to nested object mapping.

Is it possible, for example, to achieve the same result with pydantic?

https://stackoverflow.com/questions/71574543/how-to-transform-data-for-pydantic-models

I've evaluated dpath-python and pydantic.

Pydantic would help with model design but doesn't seem to solve the dynamic aspect. Code would still need to be modified if the structure of the index query results change afaik. Maybe with a bit of ninjutsu it could work.

Dpath can handle this but felt at the time like cracking a nut with a sledghammer. But in retrospect, for performance and maintainability, it looks like the better way to go.