--// Create
=======================================================
POST https://localhost:9200/carconfigindex/cartitle/1
{
"title":"Toyota 4x4"
}
POST https://localhost:9200/carconfigindex/cartitle/2
{
"title":"Toyota 4WD"
}
POST https://localhost:9200/carconfigindex/cartitle/3
{
"title":"Toyota Four Wheel Driver"
}
--// How to improve your full-text search in ElasticSearch with NGram Tokenizer
=======================================================
https://devticks.com/how-to-improve-your-full-text-search-in-elasticsearch-with-ngram-tokenizer-e346f29f8ddb
--// Quick Search
=======================================================
GET https://localhost:9200/carconfigindex/cartitle/_search?q=title:4x4
--// Query Search
=======================================================
GET https://localhost:9200/countries/countryname/_search
{
"query": {
"query_string": {
"fields": [
"countryName"
],
"default_operator": "AND",
"query": "us"
}
}
}
--// Map Search using Sysnoms
=======================================================
GET https://localhost:9200/carconfigindex/cartitle/_search?q=title:4x4
--// Creating a new Map
=======================================================
curl -XPUT 'https://localhost:9200/advert_index/_mapping/advert_type' -d '
{
"advert_type" : {
"properties" : {
"message" : {"type" : "string", "store" : "yes"}
}
}
}
--// Synonyms file configuration (Description)
=======================================================
DELETE /test_index
PUT /test_index
{
"settings": {
"index" : {
"analysis" : {
"analyzer" : {
"turners_standard" : {
"type": "custom",
"tokenizer" : "standard",
"filter" : ["lowercase", "synonym_filter"]
}
},
"filter" : {
"synonym_filter" : {
"type" : "synonym",
"lenient": true,
"synonyms" : ["4x4, 4WD => Four Wheel Drive"]
}
}
}
}
},
"mappings": {
"car": {
"properties": {
"model": { "type": "text", "analyzer": "turners_standard" }
}
}
}
}
POST /test_index/car/1
{
"model": "4WD"
}
POST /test_index/car/2
{
"model": "4x4"
}
POST /test_index/car/3
{
"model": "Four Wheel Drive"
}
GET https://localhost:9200/test_index/_search?q=model:4x4
GET https://localhost:9200/test_index/car/_search?q=model:4WD
GET https://localhost:9200/test_index/car/_search?q=model:Four Wheel Drive
GET https://localhost:9200/test_index/_search?pretty
--// Synonyms file configuration (File)
=======================================================
DELETE /test_index
PUT /test_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" }
}
}
}
}
POST /test_index/car/1
{
"model": "Toyota Rav 4WD"
}
POST /test_index/car/2
{
"model": "Toyota Rav 4x4"
}
POST /test_index/car/3
{
"model": "Toyota Rav Four Wheel Drive"
}
POST /test_index/car/4
{
"model": "Toyota Rav Tow Bar"
}
GET https://localhost:9200/test_index/_search?q=model:4x4
GET https://localhost:9200/test_index/car/_search?q=model:4WD
GET https://localhost:9200/test_index/car/_search?q=model:Tow bar
GET https://localhost:9200/test_index/_search?pretty