cancel
Showing results for 
Search instead for 
Did you mean: 

delete products from solr index

Former Member
0 Kudos

Products may be deleted from catalog and when it happens these products should be deleted from solr index.

I can not select PKs of these products as they do not exist.

Is there any way to implement it?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

You can use IndexerService methods which can be used to delete selected document from indexed type. eg : void deleteTypeIndex(FacetSearchConfig arg0, IndexedType arg1, List arg2) throws IndexerException;

agupta
Explorer
0 Kudos

This will not work.

radek_michalczyk
Explorer
0 Kudos

Hi,

full indexing for sure solve problem - but it may be long process and therefore not the best in all cases. Intercpetor works fine in case products are removed manually - one by one, not very often. In case you have batch process that removes big amount pf products sending update to SOLR to remove them one by one can be peformance issue. You may consider some other solutions: - don't remove products but just make them not active (use existing or create new field on product level). It should be fairly easy to add Personalization that will hide these products in frontend. Then extend Job for removing products from SOLR. First of all it will extract proper products then it will remove them from DB at the end of this process. This is quite big change so again not sure if valid for you.

Second idea from me would be to create simple item that will store all PKs of products that were removed from system. Interceptor will create them each time product is removed. Modified job will not ask for products but for these new items and use PKs from them.

Former Member
0 Kudos

You can add a Remove Interceptor to intercept product deletions.

When a deletion is detected, st Solr delete job to delete that product from Solr index.

Alternatively, you can create a cron job to periodically get all the document IDs from the Solr index, compare them with products in the catalog, then delete the orphaned documents.

Former Member
0 Kudos

Hi, how frequently do you need to delete the products. My belief is that you need not delete from index based on PK. You just have to do a full re-indexing. Hope this helps.

Former Member
0 Kudos

Index is updated several times per day, I do not know exact intervals.

I thought about storing all PKs that are currently in solr index (or querying solr each time) and using this information to determine what products should be deleted.

Full index will really solve the problem, but I need to check how often products should be removed from index.