Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Triggering an update for the search index of a page

Nicholas May 19, 2014

Hello!

I have a macro that updates the body of itself on a page. Since page.setBodyContentAsString is used, the page version is kept and the new body content is not indexed in searches.

How can I trigger an update of the search index for a single page manually?

I have looked at the LuceneIndexer class, but I am unsure how to acquire the LuceneConnection it seems to require, or even if it is the right class in the first place. This is in Confluence 5.4 and 5.5.

Any ideas on which class can do what I ask?

Best regards

Nicho

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Nicholas May 20, 2014

Hello Rodrigo,

Thank you for the link to the other thread! After poking around with ConfluenceIndexManager as suggested there, I noticed that there is also a ConfluenceIndexer which is injectable. After running confluenceIndexer.reIndex(page), I could immediately se the updated contents of the page in the search. Perhays this is a feature that has been added after that thread was created? Regardless, this seems to have fixed my problem perfectly! :)

Anyway, to give this some context, what I was creating is an excerpt and excerpt include macro where the content that is included on a page is also searchable. The workaround here is to put the excerpt into the body of the excerpt include macro, and then reindex. Also, a cool note: This works even if the bodytype is set to none, thus hiding the inserted body from anyone who edits the page!

If immediate indexing is not required the other way to do it is to use ConfluenceIndexManager:

confluenceIndexManager.getTaskQueue().enqueue(new IndexTaskFactory().createUpdateDocumentTask(page));

(This seems to adhere to the queue, and is probably better if immediate searching is not required, but correct me if I am wrong).

Best regards

Nicho

1 vote
Rodrigo Girardi Adami
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 19, 2014

Hi Nicho,

I've investigated this possibility and it seems that confluence doesn't provide this functionality for single pages as we can see in this answer.

According the answer, you'll have some problem if you try the workaround provided.

regards,

Rodrigo

TAGS
AUG Leaders

Atlassian Community Events