This is an example using ElasticSearch with JQuery and Python, I built that concept using synonyms in Windows. Thanks to my friend Ricardo for your support ;)
The challenge was to build a solution that would be able to search by a word to return the synonyms like that:
To build it, I needed to set up the environment, so I followed it up:
1º - INSTALL THE ELASTICSEARCH
I Installed the Windows version for a pure concept.
2º - INSTALL SENSE
It's a helpful tool for testing and development
3º - INSTALL ELASTICSEARCH HEAD
A relevant tool to check the indexes, build queries.
4º - INSTALL ELASTICSEARCH TOOLBOX
Another relevant tool to check the indexes and validate the connections.
5º - ELASTIC SHARED ACCESS PERMISSION
To all the users be able to access the Elastic, it's necessary to change the Elastic configuration file located on C:\ProgramData\Elastic\Elasticsearch\config\elasticsearch.yml
6º - REMOTE ELASTIC CONFIGURATION
To make possible the access out of the box (localhost), it's necessary to change the host configuration:
7º - CONFIGURE THE SYNONYMS
To make the search much more powerful, I configured the synonym files (next step), I used the website called: www.thesaurus.com for it:
8º - CONFIGURE THE SYNONYM FILES
I created a folder named analysis, it must be inside the ES configuration path, in my case it was: C:\ProgramData\Elastic\Elasticsearch\config\analysis
9º - CONFIGURE THE WINDOWS IIS
I used IIS because I'm using Windows, it made a difference when I needed to test JQuery:
10º - CONFIGURE ELASTICSEARCH FOR SYNONYMS
First of all, we need to set up ES to use the synonyms using Sense:
PUT /concept_index
{
"settings": {
"index" : {
"analysis" : {
"analyzer" : {
"car_standard_synonyms" : {
"type": "custom",
"tokenizer" : "standard",
"filter" : ["lowercase", "synonym_filter"]
}
},
"filter" : {
"synonym_filter" : {
"type" : "synonym",
"lenient": true,
"synonyms_path":"analysis/synonyms.txt"
}
}
}
}
},
"mappings": {
"car": {
"properties": {
"model": { "type": "text", "analyzer": "car_standard_synonyms" }
}
}
}
}
11º - LOAD THE DATA FROM MSSQL SQL TO ELASTICSEARCH
I used Python to do it, it took 2 seconds to load 3500 records, this is the code:
12º - FINALLY - JQUERY TO SEARCH ELASTICSEARCH
I saved the JQuery inside of the index.html file C:\inetpub\wwwroot: