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

Allow custom formatting of objectID #240

Open
mkilmanas opened this issue Apr 7, 2023 · 2 comments
Open

Allow custom formatting of objectID #240

mkilmanas opened this issue Apr 7, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mkilmanas
Copy link
Contributor

Description
Right now, SearchEntity has a fixed method to generate the objectID from doctrine's primary key. The problem is that objectIDs are limited in what characters they can contain (e.g. : is disallowed) - so this limits what values can be used in the Doctrine's entity fields if the entity has to be indexable/searchable.
We need a possibility to override/customize this method in order to map entity data to acceptable objectID.

Basic example
In our case we have CustomerAccount entity, which has a composite primary key made of two columns 'context' and 'account_id'. However, account_ids sometimes contain : character, which is not allowed in ObjectID, so these entities fail to to be indexed.

Other
There are multiple ways how this could be addressed, here's a few rough ideas:

  • Introduce IdNormalizerInterface so that custom service can be implemented and then it would be used to generate the id for the SearchEntity
  • Allow configuration to tell which entity getter should be called to get the objectID for it
  • Generally make the current method cleanup the value to be compatible with the engine requirements (as long as ObjectID is never used for mapping back to the entity). Or it could use even use a hash function for objectID (and include the raw values as attributes)
@brunoocasali brunoocasali added enhancement New feature or request good first issue Good for newcomers labels Apr 10, 2023
@brunoocasali
Copy link
Member

Hey @mkilmanas. I agree with implementing this!

We might not have enough time to work on it in the following weeks. Also, I will add some details to this issue to make the implementation easier. If someone wants to contribute and implement it, it will be released faster! PRs are always welcome!

Also, there is some related issues to this topic: #66 and #58

@mkilmanas
Copy link
Contributor Author

I see Aggregator model (which is then extended by Aggregator Entity and Document) has similar logic (mapping entity to object ID and back) - maybe that the way to go, and make it equally apply to all Entities, not only those extending Aggregator (extending somehow doesn't sound right at this point in general)?

Although to me it still feels that an external service (like Normalizer/Denormalizer) would be the cleanest solution.

And from those other threads - did I get it right, there is a desire to completely get rid of objectID field? Or just how it is produced/used? Or just the naming?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants