force SOLR6 re/indexing from code

cancel
Showing results for 
Search instead for 
Did you mean: 
LukaszRo
Member II

force SOLR6 re/indexing from code

Hi,

I have a problem with SOLR6 re/indexing.
I know that by default SOLR is re/indexed every 15 seconds and it is fine.
The challange I am facing is that I would like to force/trigger re/indexation process in the code for some created or modified nodes.
Is there a way to re/index node after being created or modified?
If it is possible, are there any threats connected with it?

Thank you in advance for solution or suggestion.

3 Replies
abhinavmishra14
Advanced

Re: force SOLR6 re/indexing from code

Ideally you don't have to force re-index from code. Indexes are eventually consistent. And if you see issues with index, you should try to re-index via solr admin console. 

Default interval for index tracking is 10 seconds (although docs says 15 seconds) and its configurable. 

You can partially re-index with help of 

/solr/admin/cores?action=SUMMARY&wt=xml , /solr/admin/cores?action=REPORT&wt=xml  

/solr/admin/cores?action=REINDEX&txid=3212 or /solr/admin/cores?action=FIX or /solr/admin/cores?action=RETRY

Background from TTL (you should watch it to learn more): https://www.alfresco.com/events/webinars/tech-talk-live-reindexing-large-repositories

indexing-process.PNG

indexing-process2.PNG

 

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
LukaszRo
Member II

Re: force SOLR6 re/indexing from code

@abhinavmishra14 thank you for your response. I don't want to change solr index tracking configuration to make it more frequent (my need would be probably 1 second), because I am afraid that such frequent interval would slow down significantly the system.

The case is that  a end-user is creating/modifing a node and if that node is not re/indexed it wouldn't be showed at all or showed with not modified properties. My goal is to show the end-user up-to-date properties. That's why I would like to run re/index process from the code to show the end-user the changes he/she made.

openpj
Moderator
Moderator

Re: force SOLR6 re/indexing from code

You can add the indexControl aspect for all the nodes that you want to reindex.

This aspect allows you to change the indexing behavior deciding how to manage indexes for that content.

You can decide if indexing only the properties or also the content and finally you could eventually want to disable the indexing process for that node and eventually re-enabled it. Take a look at the documentation:

https://docs.alfresco.com/content-services/latest/config/repository/#control-indexes

Hope this helps.