ElasticSearch
See the doc:app-search app documentation for python code.
For building the fuzzy match code, I found the following articles very useful:
Pillar
Create a search
sls
:
# config/search.sls
search:
True
And add it to the config for the server e.g:
# top.sls
'test-a':
- config.search
- sites.my
Install
For a development workstation, see elasticsearch.
Install the phoentic search plugins (See Plugins, Re-Install below).
Plugins
Re-Install
Elasticsearch version 6 (and later):
cd /usr/share/elasticsearch
sudo bin/elasticsearch-plugin remove analysis-phonetic
sudo bin/elasticsearch-plugin install analysis-phonetic
sudo systemctl restart elasticsearch.service
Tip
For more information on the Phonetic Plugins, see Custom Analyzers and Phonetic Analysis Plugin
Warning
The plugins will not update when a new version of ElasticSearch is
installed by apt
.
Note
Older versions of elasticsearch (version 5 and earlier) the plugin
maintenance program was called plugin
not
elasticsearch-plugin
.
List
cd /usr/share/elasticsearch
bin/plugin list
Background Tasks
See doc:app-search
Update
I couldn’t upgrade from an old version to 8.x and didn’t need to preserve the data, so I deleted the data folder:
apt remove elasticsearch
Find the location of the data folder in
/etc/elasticsearch/elasticsearch.yml
Delete the folder.
apt install elasticsearch
Recreate the Elasticsearch indexes.
Update to version 6
No handler for type [string]
From No handler for type [string] declared on field [name]
Elasticsearch has dropped the string
type and is now using text
, so
your code should be something like this:
'mappings': {
self.DOC_TYPE: {
"properties": {
"job_role": {
"type": "text",
"analyzer": "my_analyzer",
Plugin
If you cannot install a plugin because a previous version is still installed, then remove ElasticSearch before re-installing.
Will not start (after installing an earlier version)
Check the logs in:
/var/log/syslog
It seems that the config is driven from:
/etc/default/elasticsearch
To solve this issue I ran the following commands:
apt purge elasticsearch
rm -r /var/lib/elasticsearch/