From 746b57346ad69227e4add990201f71477bf6f0a1 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 27 Jun 2023 17:18:54 +0800 Subject: [PATCH] test: improve es index settings and mappings (#96) --- pkg/storage/elasticsearch/client_test.go | 32 +++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/pkg/storage/elasticsearch/client_test.go b/pkg/storage/elasticsearch/client_test.go index 47b77920d..f8037e88f 100644 --- a/pkg/storage/elasticsearch/client_test.go +++ b/pkg/storage/elasticsearch/client_test.go @@ -37,6 +37,31 @@ func TestNewESClientWithContext(t *testing.T) { func TestCreateIndex(t *testing.T) { a := assert.New(t) bodyStr := `{ + "settings": { + "analysis": { + "analyzer": { + "nickname_analyzer": { + "type": "custom", + "tokenizer": "ngram", + "char_filter": [ + "html_strip" + ], + "filter": [ + "lowercase", + "trim", + "unique" + ] + } + }, + "tokenizer": { + "ngram": { + "type": "ngram", + "min_gram": 2, + "max_gram": 20 + } + } + } + }, "mappings" : { "properties" : { "id" : { @@ -50,12 +75,7 @@ func TestCreateIndex(t *testing.T) { "nickname" : { "index": true, "type" : "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } + "analyzer": "partial" }, "bio" : { "index": true,