-
Notifications
You must be signed in to change notification settings - Fork 5
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
Remove recursive logic for object relation attributes metaData function #55
Conversation
7db0054
to
75a56f7
Compare
I support the general idea of stopping the indexing from going too deep. We've had to create custom indexing classes to overcome this behavior, which was affecting search relevance in a bad way. Needing to "reach deeper" is not the default use case. I think this also helps in the edge cases where you want to have the same object related multiple times in the same attribute -- but that would be for Mugo Object Relations: https://app.assembla.com/spaces/mugo-development-general/tickets/433
|
I agree with you both here. I cannot however see a good use case where data more than 1 relation 'deep' should also be present by default. That gets at what Peter mentioned in that a use case, where that is required for whatever reason, should have to enable this kind of behaviour (however that may be). eZFind is fast, but keeping the index from bloating by restricting the related data indexed would be a good step to stop this from becoming a problem in the first place. |
About where to put metaDataArray functionI agree with Peter, it's not great to have the dependency for a datatype to another datatype. But the source code bundle comes with all datatypes always - so it's not very risky to have the dependency. What are my alternative options:
My evaluation about the alternative options:
I think long term goal should be to have a single attribute for object relations. And allow to set a limit for the object relations. Then there is no need to have 2 separate datatypes. With this background, I would consider option 2. or the current implementation. |
I'd vote for 3. from your list of options, but I don't know how much effort or code changes that would require (risk of breaking stuff). |
Yes, I prefer option 2 |
The metaDataArray function is now on both datatypes which drops the dependency between the datatypes. |
Needs testing |
This is working fine. Before applying this patch, the results included the content from other related content and their relations, eg.:
After applying this patch
|
Each datatype has the function metaData(). It's used by the search engine in order to get attribute content you want to put in to the search index. For ezstring is it just the string that is stored in the attribute.
It's more complex for an object relation attribute (ezobjectrelation and ezobjectrelationlist). In that case, the metaData function is looking up the related object and collects all searchable data on the related content object.
So if you have an article with an object relation attribute to configure related articles, the metaData for that attribute will collect all data from the related article.
Now let's assume the related article also has an object relation attribute to an image object. Again, the metaData function will lookup the related object and collect all data from the image data map.
That recursive logic will follow all object relations and puts all collected data into the search index for one single attribute.
This pull request is removing the recursive logic. For an article object relation attribute, it will only collect all data of the related article. Object relations on the related article are ignored (like the image object in the previous example).
With this pull request, we will only index closely related data. It also avoids a problem the upstream version currently has: ezsystems#1288
Technical details:
I moved the function 'metaDataArray' from ezcontentobjectattribute to ezobjectrelationlisttype. That function is very specific to the ezobjectrelationlisttype and ezobjectrelationtype datatype. Only those 2 classes are calling the function. That's why I believe it does not belong to ezcontentobjectattribute.
I removed the recursion protection from ezobjectrelationlisttype and ezobjectrelationtype datatypes (function metaData). It's not needed when there is no recursion.