From 74c6f99fa59fd6a16d787d771299332ed543ba6f Mon Sep 17 00:00:00 2001 From: "Maxence G. de Montauzan" Date: Fri, 13 Aug 2021 02:34:17 +0200 Subject: [PATCH] (back) Suggester: Change ELS search analyzer for specific char 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) --- suggester.es | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/suggester.es b/suggester.es index bcdeca3..c422322 100644 --- a/suggester.es +++ b/suggester.es @@ -30,13 +30,15 @@ PUT /itunes-suggest "mappings": { "properties": { "artist_suggest": { - "type": "completion" + "type": "completion", + "search_analyzer": "names" }, "artist": { "type": "keyword" }, "album_suggest": { - "type": "completion" + "type": "completion", + "search_analyzer": "names" }, "album": { "type": "keyword" @@ -45,6 +47,8 @@ PUT /itunes-suggest } } +// 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 @@ -53,6 +57,8 @@ GET itunes-suggest/_analyze "text": "the servent" } +GET itunes-suggest/_search + POST itunes-suggest/_search { "_source" : "artist", @@ -79,3 +85,53 @@ POST itunes-suggest/_search } } } + +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" + } + } + } +}