Browse Source

increase focus weight from 10->40 and simplify population/popularity subview

pull/529/head
missinglink 9 years ago
parent
commit
e40c9ef326
  1. 7
      query/autocomplete.js
  2. 2
      query/autocomplete_defaults.js
  3. 16
      query/view/pop_subquery.js
  4. 10
      test/unit/fixture/autocomplete_linguistic_final_token.js
  5. 12
      test/unit/fixture/autocomplete_linguistic_focus.js
  6. 12
      test/unit/fixture/autocomplete_linguistic_focus_null_island.js
  7. 10
      test/unit/fixture/autocomplete_linguistic_multiple_tokens.js
  8. 10
      test/unit/fixture/autocomplete_linguistic_only.js
  9. 10
      test/unit/fixture/autocomplete_linguistic_with_admin.js
  10. 10
      test/unit/fixture/autocomplete_with_source_filtering.js

7
query/autocomplete.js

@ -9,7 +9,8 @@ var views = {
ngrams_strict: require('./view/ngrams_strict'), ngrams_strict: require('./view/ngrams_strict'),
focus_selected_layers: require('./view/focus_selected_layers'), focus_selected_layers: require('./view/focus_selected_layers'),
ngrams_last_token_only: require('./view/ngrams_last_token_only'), 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 // scoring boost
query.score( views.focus_selected_layers( views.ngrams_strict ) ); query.score( views.focus_selected_layers( views.ngrams_strict ) );
query.score( peliasQuery.view.popularity( views.ngrams_strict ) ); query.score( peliasQuery.view.popularity( views.pop_subquery ) );
query.score( peliasQuery.view.population( views.ngrams_strict ) ); query.score( peliasQuery.view.population( views.pop_subquery ) );
// non-scoring hard filters // non-scoring hard filters
query.filter( peliasQuery.view.sources ); query.filter( peliasQuery.view.sources );

2
query/autocomplete_defaults.js

@ -33,7 +33,7 @@ module.exports = _.merge({}, peliasQuery.defaults, {
'focus:offset': '0km', 'focus:offset': '0km',
'focus:scale': '250km', 'focus:scale': '250km',
'focus:decay': 0.5, 'focus:decay': 0.5,
'focus:weight': 10, 'focus:weight': 40,
'function_score:score_mode': 'avg', 'function_score:score_mode': 'avg',
'function_score:boost_mode': 'multiply', 'function_score:boost_mode': 'multiply',

16
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;
};

10
test/unit/fixture/autocomplete_linguistic_final_token.js

@ -20,11 +20,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'one', 'query': 'one',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },
@ -45,11 +42,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'one', 'query': 'one',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },

12
test/unit/fixture/autocomplete_linguistic_focus.js

@ -40,7 +40,7 @@ module.exports = {
'decay': 0.5 'decay': 0.5
} }
}, },
'weight': 10 'weight': 40
}], }],
'score_mode': 'avg', 'score_mode': 'avg',
'boost_mode': 'multiply', 'boost_mode': 'multiply',
@ -64,11 +64,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },
@ -89,11 +86,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },

12
test/unit/fixture/autocomplete_linguistic_focus_null_island.js

@ -40,7 +40,7 @@ module.exports = {
'decay': 0.5 'decay': 0.5
} }
}, },
'weight': 10 'weight': 40
}], }],
'score_mode': 'avg', 'score_mode': 'avg',
'boost_mode': 'multiply', 'boost_mode': 'multiply',
@ -64,11 +64,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },
@ -89,11 +86,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },

10
test/unit/fixture/autocomplete_linguistic_multiple_tokens.js

@ -31,11 +31,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'one two three', 'query': 'one two three',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },
@ -56,11 +53,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'one two three', 'query': 'one two three',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },

10
test/unit/fixture/autocomplete_linguistic_only.js

@ -20,11 +20,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },
@ -45,11 +42,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },

10
test/unit/fixture/autocomplete_linguistic_with_admin.js

@ -86,11 +86,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'one two', 'query': 'one two',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },
@ -114,11 +111,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'one two', 'query': 'one two',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },

10
test/unit/fixture/autocomplete_with_source_filtering.js

@ -20,11 +20,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },
@ -45,11 +42,8 @@ module.exports = {
'query': { 'query': {
'match': { 'match': {
'name.default': { 'name.default': {
'analyzer': 'peliasQueryPartialToken', 'analyzer': 'peliasQueryFullToken',
'boost': 100,
'query': 'test', 'query': 'test',
'type': 'phrase',
'operator': 'and'
} }
} }
}, },

Loading…
Cancel
Save