collective / Products.PloneKeywordManager

Change, merge and delete keywords (AKA tags or subjects) in Plone.
https://pypi.org/project/Products.PloneKeywordManager/
4 stars 8 forks source link

Delete all unused keywords in a site #39

Closed tobiasherp closed 1 year ago

tobiasherp commented 3 years ago

I have a Plone 4 site where a colleague of mine installed Products.PloneKeywordManager v2.1 years ago and created hundreds of keywords which might have been useful but have never been actually used.

Now, to start actually using it, we'd like to have a handy short list of keywords (which will then eventually grow as needed, of course).

It seems to me, the only suggested way to delete keywords is: select one or more keywords, and replace them by another one.

This makes sense for actually used keywords, but it is no solution for my situation where nearly all keywords are unused.

So, here is my feature request: Could we please have a facility to (list and) delete all unused keywords?

If it exists in the Plone-5-only v3 branch -- could it be merged back to v2?

Thank you!

flipmcf commented 2 years ago

I think if you drop and re-index the keyword index, you will remove all the unused keywords.

http://localhost:8080/Plone/portal_catalog/manage_catalogIndexes select the 'Subject' index. Then click 'reindex' (clear and reindex might be nicer)

Do this under maintenance window. it can take a while. All the objects in the database will be opened, the subject field will be inspected, and every keyword it finds gets placed back into the index. (leaving the unused ones deleted)

tobiasherp commented 2 years ago

@flipmcf :

I think if you drop and re-index the keyword index, you will remove all the unused keywords.

Ah, interesting. In my case, I made a list of all used subjects, and then removed them by hand somehow (IIRC). However, it seems somewhat suboptimal to reindex the whole site just to get rid of unused values, while all needed information could be taken from the catalog instead.

flipmcf commented 2 years ago

seems somewhat suboptimal to reindex the whole site just to get rid of unused values

I agree. And after I replied above I thought about this some more. I haven't looked at the methods available on a keywordindex (or an index in general) but if there is a method to remove a key from the index, this is the place to use it.

And I would assume that when a user 'deletes' a keyword using this tool, that keyword should be removed from the index as well.

flipmcf commented 2 years ago

I couldn't recreate this issue during my tests.

I created keywords (by editing content and adding new terms to 'subject').

i then used the keyword manager to delete the keywords. They disappeared from the index and were not available as auto-complete options on my subject field.

The only reason there would be a keyword in a keyword index is there are objects that are indexed with that value.

The concept of an 'unused keyword' is confusing to me. there must be objects using the keyword if they appear in the index.

flipmcf commented 2 years ago

I shouldn't have closed this. It's asking for the delete to be backported

gforcada commented 1 year ago

On the control panel there is a way to select tags and remove them 👍🏾