Browse Source

disable focus for single token queries, use constant_score for ngrams matching

pull/538/head
Peter Johnson 8 years ago
parent
commit
d3cd14e304
  1. 6
      query/view/focus_selected_layers.js
  2. 6
      query/view/ngrams_last_token_only.js
  3. 4
      test/unit/fixture/autocomplete_linguistic_focus.js
  4. 4
      test/unit/fixture/autocomplete_linguistic_focus_null_island.js
  5. 4
      test/unit/fixture/autocomplete_linguistic_multiple_tokens.js
  6. 4
      test/unit/fixture/autocomplete_linguistic_only.js
  7. 4
      test/unit/fixture/autocomplete_with_source_filtering.js

6
query/view/focus_selected_layers.js

@ -14,6 +14,12 @@ var peliasQuery = require('pelias-query');
module.exports = function( subview ){
return function( vs ){
// don't perform this query on single character inputs
// as its too unperformant to sort a large part of the index.
if( vs.var('input:name').get().length < 2 ){
return null;
}
if( !subview ){ return null; } // subview validation failed
var macroView = peliasQuery.view.focus( subview );
if( !macroView ){ return null; } // macroView validation failed

6
query/view/ngrams_last_token_only.js

@ -28,5 +28,9 @@ module.exports = function( vs ){
vsCopy.var('input:name').set( tokens.join(' ') );
// return the view rendered using the copy
return ngrams_strict( vsCopy );
return {
'constant_score': {
'query': ngrams_strict( vsCopy )
}
};
};

4
test/unit/fixture/autocomplete_linguistic_focus.js

@ -3,6 +3,8 @@ module.exports = {
'query': {
'bool': {
'must': [{
'constant_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
@ -13,6 +15,8 @@ module.exports = {
'slop': 3
}
}
}
}
}],
'should': [{
'function_score': {

4
test/unit/fixture/autocomplete_linguistic_focus_null_island.js

@ -3,6 +3,8 @@ module.exports = {
'query': {
'bool': {
'must': [{
'constant_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
@ -13,6 +15,8 @@ module.exports = {
'slop': 3
}
}
}
}
}],
'should': [{
'function_score': {

4
test/unit/fixture/autocomplete_linguistic_multiple_tokens.js

@ -14,6 +14,8 @@ module.exports = {
}
},
{
'constant_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
@ -24,6 +26,8 @@ module.exports = {
'slop': 3
}
}
}
}
}],
'should':[
{

4
test/unit/fixture/autocomplete_linguistic_only.js

@ -3,6 +3,8 @@ module.exports = {
'query': {
'bool': {
'must': [{
'constant_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
@ -13,6 +15,8 @@ module.exports = {
'slop': 3
}
}
}
}
}],
'should':[{
'function_score': {

4
test/unit/fixture/autocomplete_with_source_filtering.js

@ -3,6 +3,8 @@ module.exports = {
'query': {
'bool': {
'must': [{
'constant_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
@ -13,6 +15,8 @@ module.exports = {
'slop': 3
}
}
}
}
}],
'should':[{
'function_score': {

Loading…
Cancel
Save