From 80c14628664a3a425fab1279fe989fcea25b9c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Sat, 3 Aug 2019 00:25:39 +0300 Subject: [PATCH] improve search result relevance --- CHANGELOG.md | 1 + backend/lib/backend/api.ex | 11 ++++------- backend/priv/elasticsearch/instances.json | 24 +++++------------------ 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45dcbfe..d2e8c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Performance improvements when opening the app on something that isn't the graph. +- There are now fewer irrelevant search results. ### Deprecated diff --git a/backend/lib/backend/api.ex b/backend/lib/backend/api.ex index 2521054..8b3d017 100644 --- a/backend/lib/backend/api.ex +++ b/backend/lib/backend/api.ex @@ -115,6 +115,7 @@ defmodule Backend.Api do "sort" => "_score", "from" => from, "size" => page_size, + "min_score" => 1, "query" => %{ "bool" => %{ "filter" => %{ @@ -127,7 +128,8 @@ defmodule Backend.Api do "multi_match" => %{ "query" => query, "fields" => [ - "description.english" + "description.english", + "domain.english" ] } }, @@ -143,14 +145,9 @@ defmodule Backend.Api do "wildcard" => %{ "domain.keyword" => %{ "value" => "*#{query}*", - "boost" => 1 + "boost" => 50 } } - }, - %{ - "match" => %{ - "domain.ngram^0.5" => query - } } ] } diff --git a/backend/priv/elasticsearch/instances.json b/backend/priv/elasticsearch/instances.json index 2151b60..714889b 100644 --- a/backend/priv/elasticsearch/instances.json +++ b/backend/priv/elasticsearch/instances.json @@ -1,21 +1,7 @@ { "settings": { "number_of_shards": 1, - "number_of_replicas": 0, - "analysis": { - "analyzer": { - "ngramAnalyzer": { - "tokenizer": "ngramTokenizer" - } - }, - "tokenizer": { - "ngramTokenizer": { - "type": "ngram", - "min_gram": 5, - "max_gram": 5 - } - } - } + "number_of_replicas": 0 }, "mappings": { "_doc": { @@ -23,12 +9,12 @@ "domain": { "type": "text", "fields": { - "ngram": { - "type": "text", - "analyzer": "ngramAnalyzer" - }, "keyword": { "type": "keyword" + }, + "english": { + "type": "text", + "analyzer": "english" } } },