Open wesleybl opened 5 months ago
In fact, the problem occurs even if the Subject
is made up of just one word. I updated the description to accommodate this.
I debugged this error and came to the following conclusions:
Subject
index:Subject
is left behindSubject
, those that have the value that is in "not" are removed:But why does it sometimes work? Let's go:
allowedRolesAndUsers
is always used:Subject
index, two indexes are used internally (Subject
and allowedRolesAndUsers
).Subject
and sometimes it is allowedRolesAndUsers
. allowedRolesAndUsers
, all records are included in the results, including those that do not have the Subject
field. So it works correctly without missing content.Subject
is the first index, there is the problem of leaving content without Subject
behind, because we don't have all the records pre-selected.So this problem can occur in all indexes where not all content has a value, not just with Subject
.
How to fix this problem?
I could think about forcing the index allowedRolesAndUsers
to always be first. But it is a Plone-specific index, which Products.ZCatalog
"does not know".
Could we force indexes with "not" to always be last?
Or do something like: If the search result is empty and the index contains a "not", search all records first. But how and where to do this?
@mauritsvanrees @davisagli @mamico @jensens I'm mentioning you because you recently messed with Products.ZCatalog
. Opinions?
I could think about forcing the index allowedRolesAndUsers to always be first. But it is a Plone-specific index, which Products.ZCatalog "does not know".
In fact, allowedRolesAndUsers
exists in Zope too:
@dataflake @icemac any thoughts here?
The index is not in Zope, it's in Products.CMFCore where the only "consumer" is Plone. I am not a ZCatalog expert, sorry.
@wesleybl I think changing the order of the indexes should mitigate the problem, but in the end it won't be the real solution.
However, if you want to experiment, you can do so by monkey-patching the method Products.ZCatalog.Catalog.Catalog_sorted_search_indexes
, you can find inspiration here https://github.com/RedTurtle/redturtle.volto/blob/master/src/redturtle/volto/catalogplan.py
In the meantime, I would try opening an issue or a PR (starting with a test that breaks) on Products.ZCatalog
.
I also see a similar problem, not the same one, here https://github.com/zopefoundation/Products.ZCatalog/issues/35 and some work done, but probably not fully completed, here https://github.com/zopefoundation/Products.ZCatalog/pull/74
\cc @andbag @d-maurer
I think changing the order of the indexes should mitigate the problem, but in the end it won't be the real solution.
@mamico I think this would solve the problem in a simpler way. At least it would solve the problem for those using Plone
or Products.CMFCore
, which I believe are the biggest users of Zope
.
Any other solution would be more complex and would have to allow returning all objects in the catalog before applying the filter with not.
BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)
When we do a search in the
Subject
index, with "not", the result is sometimes wrong. Sometimes it returns an empty list, when it should return content.What I did:
What I expect to happen:
The search must return all content that does not contain the "Bulletin" Tag
What actually happened:
Sometimes an empty list is returned.
What version of Plone/ Addons I am using:
Plone 6.0.9