• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Content search following Merge Users

Harpers Tate

Well-known member
#1
Two user accounts were merged in the AdminCP, because they belonged to the same person. (let's call them Member 1, Member 2 for example). Member 1 remains; Member 2 is deleted by the merge.

Following this action, on the User Profile for Member 1, Postings Tab, link "Find all content by Member 1" the resultant list does NOT include content posted originally by Member 2.

In the forum itself, an affected post DOES correctly show the Member 1 as the author.
 

Mike

XenForo developer
Staff member
#3
Rebuilding the search index would fix it, yes, but that's not exactly ideal.

However, I'm not sure I see a particularly good way of fixing this, at least at scale. The problem is, every indexed content "owned" by a user needs to be changed to a new user. As search is designed to be very dynamic and add-on changeable, detecting this is tricky. In MySQL FT, we could run a query, but we can't do that with ES.

I can see an approach to do this, but I'm not positive yet.
 

AndyB

Well-known member
#6
That was the first line of my comment. The rest relates to not doing that.
Hi Mike,

Please explain why the ES search would not be updated when we rebuild the index. I assume the xf_post user_id and username information is correct, or is that the problem, the xf_post table is not updated?
 

Jeremy

Well-known member
#7
Rebuilding the search index would fix it, yes, but that's not exactly ideal.
Rebuilding it would fix it. As stated twice by the line above. But this is not the ideal fix, as it should update automatically allowing no manual interaction. ES functions differently in how it stores documents -- and that is the issue. It's not easy as saying "take all these documents and change this data too that".

Rebuilding the search index takes ALL documents, throws them out and uses the updated information in the relative XF tables to construct a new index. This can be time consuming and not ideal for most boards.
 

AndyB

Well-known member
#8
Thank you for the clarification, Jeremy.

Sorry Mike, for some reason when I read "would" in my mind I saw "wouldn't".
 

Daniel Hood

Well-known member
#9
Couldn't you execute a search through the XenForo_Searcher class for all content by that user. If you modified it to loop through all the results and compile a list of content types/content ids, you should be able to update just those. It still might be somewhat time consuming but it seems like a perfect task for the deferred system. Since it's going through the XenForo_Searcher class, it should work with ElasticSearch too. ElasticSearch just may have to be modified to use the scan&scroll feature.

[Edit] I just realized how old this thread is, sorry.
 

Mike

XenForo developer
Staff member
#12
XF2 has a generic approach to resolving this without a full index rebuild, though it does also allow specific search source handlers to implement an alternative approach (if they can do it more efficiently).