XenForo Elasticsearch ICU_plugin for Unicode accent-insensitive search

CR LEAKS

CR LEAKS

Administrative
Joined
Mar 25, 2022
Messages
1,272
Reaction score
5,191
Points
113
Credits
19,896
I have been asked to share this with the community. These are my notes for using the ICU_plugin with Elasticsearch on Xenforo. In this, I create a separate "field" so that the normal XF index is left alone and this is added. It makes it easy for me to change from one to the other.

I am no expert. If anybody knows better, please comment. Also, if this fails, a reinstall of the Enhanced Search add-on will probably restore your search back to normal.

If anybody from XF looks at this, it would be nice to have the option of native support for the ICU_plugin so that none of this would be necessary for international users who want better accent-insensitive search.

Here are my notes:

I use CentOS 7. If you use some other flavor of linux, many things will be different. To do this, you are expected to have a high level of understanding or the ability to learn it.
Instructions are for ElasticSearch 7.6.

Install Elasticsearch, XF Enhanced Search plugin, get it working normally. Search must work at this point.
Admin Control Panel > Setup > Enhanced Search: If "Optimization required", click it and rebuild search indexes. Maybe turn off search first.


Install analysis-icu plugin:
Disable automatic upgrades of elasticsearch. The icu_plugin must be upgraded manually with each elasticsearch upgrade or it will cause problems.
- If you use yum-cron as I do, then disable elasticsearch from auto-upgrading:
vim /etc/yum/yum-cron.conf

# manually upgrade elasticsearch and analysis-icu plugin
exclude=elasticsearch*

systemctl restart yum-cron

install analysis-icu plugin:
/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
systemctl start elasticsearch

#if upgrading elasticsearch, remove and reinstall:
/usr/share/elasticsearch/bin/elasticsearch-plugin remove analysis-icu
/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
systemctl start elasticsearch

I use Kibana to edit elasticsearch. If you do, make sure that only your IP can access it.
You can also use curl, but Kibana's Console is easier for me.
service start kibana
wait a few minutes
go to Kibana>Dev Tools>Console
CSS:
Please, Log in or Register to view codes content!
Then rebuild indexes in the AdminCP.

edit:
vim src/addons/XFES/Search/Source/Elasticsearch.php



Code:
Please, Log in or Register to view codes content!

Test accent sensitivity / case folding. It should work now.

Going forward:

  • When upgrading Elasticsearch, you MUST also remove and re-install the ICU plugin. Don't forget.
  • In the Xenforo control panel, I believe you should never click "Optimize Now". (Correct me if you find that I'm wrong.)

Good luck and cheers!
 
4,485Threads
10,412Messages
39,631Members
mika67Latest member
Top