From e40c9ef32623f78e8a3405779eba1e84287d8091 Mon Sep 17 00:00:00 2001 From: missinglink Date: Fri, 15 Apr 2016 15:21:53 +0200 Subject: [PATCH] increase focus weight from 10->40 and simplify population/popularity subview --- query/autocomplete.js | 7 ++++--- query/autocomplete_defaults.js | 2 +- query/view/pop_subquery.js | 16 ++++++++++++++++ .../autocomplete_linguistic_final_token.js | 10 ++-------- .../fixture/autocomplete_linguistic_focus.js | 12 +++--------- .../autocomplete_linguistic_focus_null_island.js | 12 +++--------- .../autocomplete_linguistic_multiple_tokens.js | 10 ++-------- .../unit/fixture/autocomplete_linguistic_only.js | 10 ++-------- .../autocomplete_linguistic_with_admin.js | 10 ++-------- .../autocomplete_with_source_filtering.js | 10 ++-------- 10 files changed, 37 insertions(+), 62 deletions(-) create mode 100644 query/view/pop_subquery.js diff --git a/query/autocomplete.js b/query/autocomplete.js index ffc57396..0416163d 100644 --- a/query/autocomplete.js +++ b/query/autocomplete.js @@ -9,7 +9,8 @@ var views = { ngrams_strict: require('./view/ngrams_strict'), focus_selected_layers: require('./view/focus_selected_layers'), ngrams_last_token_only: require('./view/ngrams_last_token_only'), - phrase_first_tokens_only: require('./view/phrase_first_tokens_only') + phrase_first_tokens_only: require('./view/phrase_first_tokens_only'), + pop_subquery: require('./view/pop_subquery') }; //------------------------------ @@ -38,8 +39,8 @@ query.score( peliasQuery.view.admin('neighbourhood') ); // scoring boost query.score( views.focus_selected_layers( views.ngrams_strict ) ); -query.score( peliasQuery.view.popularity( views.ngrams_strict ) ); -query.score( peliasQuery.view.population( views.ngrams_strict ) ); +query.score( peliasQuery.view.popularity( views.pop_subquery ) ); +query.score( peliasQuery.view.population( views.pop_subquery ) ); // non-scoring hard filters query.filter( peliasQuery.view.sources ); diff --git a/query/autocomplete_defaults.js b/query/autocomplete_defaults.js index da0791ef..cacc8297 100644 --- a/query/autocomplete_defaults.js +++ b/query/autocomplete_defaults.js @@ -33,7 +33,7 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'focus:offset': '0km', 'focus:scale': '250km', 'focus:decay': 0.5, - 'focus:weight': 10, + 'focus:weight': 40, 'function_score:score_mode': 'avg', 'function_score:boost_mode': 'multiply', diff --git a/query/view/pop_subquery.js b/query/view/pop_subquery.js new file mode 100644 index 00000000..bde1492b --- /dev/null +++ b/query/view/pop_subquery.js @@ -0,0 +1,16 @@ + +var peliasQuery = require('pelias-query'); + +/** + Population / Popularity subquery +**/ + +module.exports = function( vs ){ + + var view = peliasQuery.view.ngrams( vs ); + + view.match['name.default'].analyzer = 'peliasQueryFullToken'; + delete view.match['name.default'].boost; + + return view; +}; diff --git a/test/unit/fixture/autocomplete_linguistic_final_token.js b/test/unit/fixture/autocomplete_linguistic_final_token.js index e100206b..fc431c77 100644 --- a/test/unit/fixture/autocomplete_linguistic_final_token.js +++ b/test/unit/fixture/autocomplete_linguistic_final_token.js @@ -20,11 +20,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'one', - 'type': 'phrase', - 'operator': 'and' } } }, @@ -45,11 +42,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'one', - 'type': 'phrase', - 'operator': 'and' } } }, diff --git a/test/unit/fixture/autocomplete_linguistic_focus.js b/test/unit/fixture/autocomplete_linguistic_focus.js index bcb18d0d..430d43c9 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus.js +++ b/test/unit/fixture/autocomplete_linguistic_focus.js @@ -40,7 +40,7 @@ module.exports = { 'decay': 0.5 } }, - 'weight': 10 + 'weight': 40 }], 'score_mode': 'avg', 'boost_mode': 'multiply', @@ -64,11 +64,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } }, @@ -89,11 +86,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } }, diff --git a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js index 65a3146d..9a4afc05 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js +++ b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js @@ -40,7 +40,7 @@ module.exports = { 'decay': 0.5 } }, - 'weight': 10 + 'weight': 40 }], 'score_mode': 'avg', 'boost_mode': 'multiply', @@ -64,11 +64,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } }, @@ -89,11 +86,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } }, diff --git a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js index db6c4fc4..26e5fa86 100644 --- a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js +++ b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js @@ -31,11 +31,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'one two three', - 'type': 'phrase', - 'operator': 'and' } } }, @@ -56,11 +53,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'one two three', - 'type': 'phrase', - 'operator': 'and' } } }, diff --git a/test/unit/fixture/autocomplete_linguistic_only.js b/test/unit/fixture/autocomplete_linguistic_only.js index e4fe20ee..4360f4d7 100644 --- a/test/unit/fixture/autocomplete_linguistic_only.js +++ b/test/unit/fixture/autocomplete_linguistic_only.js @@ -20,11 +20,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } }, @@ -45,11 +42,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } }, diff --git a/test/unit/fixture/autocomplete_linguistic_with_admin.js b/test/unit/fixture/autocomplete_linguistic_with_admin.js index 59e77c0c..b183bf77 100644 --- a/test/unit/fixture/autocomplete_linguistic_with_admin.js +++ b/test/unit/fixture/autocomplete_linguistic_with_admin.js @@ -86,11 +86,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'one two', - 'type': 'phrase', - 'operator': 'and' } } }, @@ -114,11 +111,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'one two', - 'type': 'phrase', - 'operator': 'and' } } }, diff --git a/test/unit/fixture/autocomplete_with_source_filtering.js b/test/unit/fixture/autocomplete_with_source_filtering.js index 5f3bcf07..075eb6d4 100644 --- a/test/unit/fixture/autocomplete_with_source_filtering.js +++ b/test/unit/fixture/autocomplete_with_source_filtering.js @@ -20,11 +20,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } }, @@ -45,11 +42,8 @@ module.exports = { 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } },