Implementing search in dashboard revealed problems when search with specific char (francois perusse) Note: it's also possible to specify an analyzer for ingestion (cherry picked from commit 24da127750c995c55d54876a1be8a4ad3bf9ce9c)
138 lines
2.9 KiB
JavaScript
138 lines
2.9 KiB
JavaScript
DELETE itunes-suggest
|
|
|
|
PUT /itunes-suggest
|
|
{
|
|
"settings": {
|
|
"analysis": {
|
|
"filter": {
|
|
"french_stop": {
|
|
"type": "stop",
|
|
"stopwords": "_french_"
|
|
},
|
|
"english_stop": {
|
|
"type": "stop",
|
|
"stopwords": "_english_"
|
|
}
|
|
},
|
|
"analyzer": {
|
|
"names": {
|
|
"tokenizer": "standard",
|
|
"filter": [
|
|
"lowercase",
|
|
"asciifolding",
|
|
"french_stop",
|
|
"english_stop"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"mappings": {
|
|
"properties": {
|
|
"artist_suggest": {
|
|
"type": "completion",
|
|
"search_analyzer": "names"
|
|
},
|
|
"artist": {
|
|
"type": "keyword"
|
|
},
|
|
"album_suggest": {
|
|
"type": "completion",
|
|
"search_analyzer": "names"
|
|
},
|
|
"album": {
|
|
"type": "keyword"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Also possible to specify analyze for ingesting => https://stackoverflow.com/questions/48304499/elasticsearch-completion-suggester-not-working-with-whitespace-analyzer
|
|
|
|
// Problem with word EP, SP
|
|
|
|
GET itunes-suggest/_analyze
|
|
{
|
|
"analyzer": "names",
|
|
"text": "the servent"
|
|
}
|
|
|
|
GET itunes-suggest/_search
|
|
|
|
POST itunes-suggest/_search
|
|
{
|
|
"_source" : "artist",
|
|
"suggest": {
|
|
"name-suggest": {
|
|
"prefix": "sou",
|
|
"completion": {
|
|
"field": "artist_suggest"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
POST itunes-suggest/_search
|
|
{
|
|
"_source" : "album",
|
|
"suggest": {
|
|
"name-suggest": {
|
|
"prefix": "new",
|
|
"completion": {
|
|
"field": "album_suggest",
|
|
"size": 20
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
POST itunes-suggest/_search
|
|
{
|
|
"_source": ["album", "artist"],
|
|
"suggest": {
|
|
"alb-suggest": {
|
|
"prefix": "sou",
|
|
"completion": {
|
|
"field": "album_suggest"
|
|
}
|
|
},
|
|
"ar-suggest": {
|
|
"prefix": "sou",
|
|
"completion": {
|
|
"field": "artist_suggest"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
POST itunes-suggest/_search
|
|
{
|
|
"_source": ["album", "artist"],
|
|
"suggest": {
|
|
"alb-suggest": {
|
|
"prefix": "Francois",
|
|
"completion": {
|
|
"field": "album_suggest"
|
|
}
|
|
},
|
|
"ar-suggest": {
|
|
"prefix": "Francois",
|
|
"completion": {
|
|
"field": "artist_suggest"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
POST itunes-suggest/_search
|
|
{
|
|
"suggest": {
|
|
"ar-suggest": {
|
|
"prefix": "Femme",
|
|
"completion": {
|
|
"field": "artist_suggest"
|
|
}
|
|
}
|
|
}
|
|
}
|