improve search result relevance

This commit is contained in:
Tao Bror Bojlén 2019-08-03 00:25:39 +03:00
parent 76ebf50c40
commit 80c1462866
No known key found for this signature in database
GPG Key ID: C6EC7AAB905F9E6F
3 changed files with 10 additions and 26 deletions

View File

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Performance improvements when opening the app on something that isn't the graph. - Performance improvements when opening the app on something that isn't the graph.
- There are now fewer irrelevant search results.
### Deprecated ### Deprecated

View File

@ -115,6 +115,7 @@ defmodule Backend.Api do
"sort" => "_score", "sort" => "_score",
"from" => from, "from" => from,
"size" => page_size, "size" => page_size,
"min_score" => 1,
"query" => %{ "query" => %{
"bool" => %{ "bool" => %{
"filter" => %{ "filter" => %{
@ -127,7 +128,8 @@ defmodule Backend.Api do
"multi_match" => %{ "multi_match" => %{
"query" => query, "query" => query,
"fields" => [ "fields" => [
"description.english" "description.english",
"domain.english"
] ]
} }
}, },
@ -143,14 +145,9 @@ defmodule Backend.Api do
"wildcard" => %{ "wildcard" => %{
"domain.keyword" => %{ "domain.keyword" => %{
"value" => "*#{query}*", "value" => "*#{query}*",
"boost" => 1 "boost" => 50
} }
} }
},
%{
"match" => %{
"domain.ngram^0.5" => query
}
} }
] ]
} }

View File

@ -1,21 +1,7 @@
{ {
"settings": { "settings": {
"number_of_shards": 1, "number_of_shards": 1,
"number_of_replicas": 0, "number_of_replicas": 0
"analysis": {
"analyzer": {
"ngramAnalyzer": {
"tokenizer": "ngramTokenizer"
}
},
"tokenizer": {
"ngramTokenizer": {
"type": "ngram",
"min_gram": 5,
"max_gram": 5
}
}
}
}, },
"mappings": { "mappings": {
"_doc": { "_doc": {
@ -23,12 +9,12 @@
"domain": { "domain": {
"type": "text", "type": "text",
"fields": { "fields": {
"ngram": {
"type": "text",
"analyzer": "ngramAnalyzer"
},
"keyword": { "keyword": {
"type": "keyword" "type": "keyword"
},
"english": {
"type": "text",
"analyzer": "english"
} }
} }
}, },