This function is now built into XenForo Enhanced Search under AdminCP > Tools > Enhanced Search Setup.
Apply custom mapping to your Elasticsearch Index
Apply custom mapping to your Elasticsearch Index
This guide is provided for users who may wish to apply custom mapping to their Elasticsearch Index.
Please note this guide is considered experimental at the time of posting. Further mappings will follow.
This guide assumes the user has basic knowledge of SSH and prior to starting the steps below has logged in as root. Please note, whilst this is a simple and easy guide, I take no responsibility for any damages or losses that may occur to your system by following the steps below. If you are unsure at any stage, please ask for assistance or seek the help of a qualified Linux Systems Administrator.
Why do it?
Elasticsearch is a highly memory intensive proccess, unoptimised users with high load levels can expect to require approximately 1gb of memory per 1 million posts to maintain satisfactory search times. This guide will attempt to reduce these requirements by approximately one quarter to one half.
The mapping in this guide was provided by Mike Tougeron from IGN. All credit for the mappings remain with him.
Step 1
Switch to your Elasticsearch data directory.
Code:
cd /var/elasticsearch
Check the current size of your index
Code:
du -ach
In the test index I used for this example the index size was 2.9gb.
Step 2
Locate your index name.
Navigate to the subfolders of your data directory until you are within the /nodes/0/indices directory.
A directory here will have the name of your Elasticsearch index. This will usually be the name of your database unless specified otherwise in the Elasticsearch settings within your XenForo Admin CP.
Step 3
Apply the new mapping. If using putty as your SSH client you can copy all of the code below and right click within the terminal window to have it all entered for you, if using this method please change the "YOUR_INDEX_NAME" prior to pasting into Putty.
Code:
curl -XPUT 'http://localhost:9200/YOUR_INDEX_NAME/post/_mapping?ignore_conflicts=true' -d '
{
"post" : {
"_source" : {
"enabled" : false
},
"properties" : {
"message" : {"type" : "string", "store" : "no"},
"title" : {"type" : "string", "store" : "no", "index" : "no"},
"date" : {"type" : "long", "store" : "yes"},
"user" : {"type" : "long", "store" : "yes"},
"discussion_id" : {"type" : "long", "store" : "yes"},
"node" : {"type" : "long", "store" : "no"},
"prefix" : {"type" : "long", "store" : "no"},
"thread" : {"type" : "long", "store" : "no", "index" : "no"}
}
}
}'
Code:
curl -XPUT 'http://localhost:9200/YOUR_INDEX_NAME/thread/_mapping?ignore_conflicts=true' -d '
{
"thread" : {
"_source" : {
"enabled" : false
},
"properties" : {
"message" : {"type" : "string", "store" : "no", "index" : "no"},
"title" : {"type" : "string", "store" : "no"},
"date" : {"type" : "long", "store" : "yes"},
"user" : {"type" : "long", "store" : "yes"},
"discussion_id" : {"type" : "long", "store" : "yes"},
"thread_id" : {"type" : "long", "store" : "yes"},
"node" : {"type" : "long", "store" : "no"},
"prefix" : {"type" : "long", "store" : "no"},
"thread" : {"type" : "long", "store" : "no", "index" : "no"}
}
}
}'
Step 4
Re-index your board from the XenForo Admin CP.
Step 5
Switch to your Elasticsearch data directory.
Code:
cd /var/elasticsearch
Check the new size of your index
Code:
du -ach
In the test index I used for this example the index size was now 1.5gb.
Hopefully, your index size should now be reduced.
Last edited: