From ef756f80552c99c0b5bdb85233f7fb964f1530d6 Mon Sep 17 00:00:00 2001 From: jecos Date: Fri, 3 Jan 2020 14:54:17 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Add=20ngram=20tokenizer=20to=20make=20?= =?UTF-8?q?"starts-with"=20queries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mapping.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/mapping.py b/mapping.py index c084061..eae3581 100644 --- a/mapping.py +++ b/mapping.py @@ -1,4 +1,26 @@ MEMBER_INDEX = { + "settings": { + "analysis": { + "analyzer": { + "autocomplete": { + "type": "custom", + "tokenizer": "standard", + "filter": [ + "lowercase", + "edge_ngram" + ] + } + }, + "filter": { + "edge_ngram": { + "type": "edgeNGram", + "min_gram": 1, + "max_gram": 20, + "side": "front" + } + } + } + }, "mappings": { "member": { "properties": { @@ -27,6 +49,7 @@ }, "firstName": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -35,6 +58,7 @@ }, "lastName": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -43,6 +67,7 @@ }, "jobTitle": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -51,6 +76,7 @@ }, "institution": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -59,6 +85,7 @@ }, "city": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -67,6 +94,7 @@ }, "state": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -75,6 +103,7 @@ }, "country": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -85,13 +114,16 @@ "type": "keyword" }, "bio": { - "type": "text" + "type": "text", + "analyzer": "autocomplete" }, "story": { - "type": "text" + "type": "text", + "analyzer": "autocomplete" }, "interests": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -106,6 +138,7 @@ }, "name": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword" @@ -120,6 +153,7 @@ "properties": { "name": { "type": "text", + "analyzer": "autocomplete", "fields": { "raw": { "type": "keyword"