Browse Source

fix borough matching for both autocomplete and search endpoints

pull/529/head
missinglink 9 years ago
parent
commit
2398f05f8d
  1. 1
      query/autocomplete.js
  2. 4
      query/autocomplete_defaults.js
  3. 1
      query/search.js
  4. 1
      query/text_parser.js
  5. 9
      test/unit/fixture/autocomplete_linguistic_with_admin.js
  6. 8
      test/unit/fixture/autocomplete_single_character_street.js
  7. 8
      test/unit/fixture/search_full_address.js
  8. 8
      test/unit/fixture/search_partial_address.js
  9. 8
      test/unit/fixture/search_regions_address.js
  10. 18
      test/unit/query/search.js

1
query/autocomplete.js

@ -34,6 +34,7 @@ query.score( peliasQuery.view.admin('country_a') );
query.score( peliasQuery.view.admin('region') );
query.score( peliasQuery.view.admin('region_a') );
query.score( peliasQuery.view.admin('county') );
query.score( peliasQuery.view.admin('borough') );
query.score( peliasQuery.view.admin('localadmin') );
query.score( peliasQuery.view.admin('locality') );
query.score( peliasQuery.view.admin('neighbourhood') );

4
query/autocomplete_defaults.js

@ -82,6 +82,10 @@ module.exports = _.merge({}, peliasQuery.defaults, {
'admin:neighbourhood:field': 'parent.neighbourhood',
'admin:neighbourhood:boost': 200,
'admin:borough:analyzer': 'peliasAdmin',
'admin:borough:field': 'parent.borough',
'admin:borough:boost': 800,
'popularity:field': 'popularity',
'popularity:modifier': 'log1p',
'popularity:max_boost': 20,

1
query/search.js

@ -30,6 +30,7 @@ query.score( peliasQuery.view.admin('country_a') );
query.score( peliasQuery.view.admin('region') );
query.score( peliasQuery.view.admin('region_a') );
query.score( peliasQuery.view.admin('county') );
query.score( peliasQuery.view.admin('borough') );
query.score( peliasQuery.view.admin('localadmin') );
query.score( peliasQuery.view.admin('locality') );
query.score( peliasQuery.view.admin('neighbourhood') );

1
query/text_parser.js

@ -9,6 +9,7 @@ or postalcode because we should only try to match those when we're sure that's w
*/
var adminFields = placeTypes.concat([
'region_a',
'borough'
]);
/**

9
test/unit/fixture/autocomplete_linguistic_with_admin.js

@ -54,6 +54,15 @@ module.exports = {
}
}
},
{
'match': {
'parent.borough': {
'analyzer': 'peliasAdmin',
'boost': 800,
'query': 'three'
}
}
},
{
'match': {
'parent.localadmin': {

8
test/unit/fixture/autocomplete_single_character_street.js

@ -56,6 +56,14 @@ module.exports = {
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.borough': {
'analyzer': 'peliasAdmin',
'boost': 800,
'query': 'laird'
}
}
}, {
'match': {
'parent.localadmin': {

8
test/unit/fixture/search_full_address.js

@ -139,6 +139,14 @@ module.exports = {
'analyzer': vs['admin:county:analyzer']
}
}
}, {
'match': {
'parent.borough': {
'query': 'new york',
'boost': vs['admin:borough:boost'],
'analyzer': vs['admin:borough:analyzer']
}
}
}, {
'match': {
'parent.localadmin': {

8
test/unit/fixture/search_partial_address.js

@ -107,6 +107,14 @@ module.exports = {
'analyzer': vs['admin:county:analyzer']
}
}
}, {
'match': {
'parent.borough': {
'query': 'new york',
'boost': vs['admin:borough:boost'],
'analyzer': vs['admin:borough:analyzer']
}
}
}, {
'match': {
'parent.localadmin': {

8
test/unit/fixture/search_regions_address.js

@ -123,6 +123,14 @@ module.exports = {
'analyzer': vs['admin:county:analyzer']
}
}
}, {
'match': {
'parent.borough': {
'query': 'manhattan',
'boost': vs['admin:borough:boost'],
'analyzer': vs['admin:borough:analyzer']
}
}
}, {
'match': {
'parent.localadmin': {

18
test/unit/query/search.js

@ -25,7 +25,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_bbox');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_linguistic_focus_bbox');
t.end();
});
@ -42,7 +42,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_bbox');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_linguistic_bbox');
t.end();
});
@ -55,7 +55,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_only');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_linguistic_only');
t.end();
});
@ -69,7 +69,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_linguistic_focus');
t.end();
});
@ -86,7 +86,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_viewport');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_linguistic_viewport');
t.end();
});
@ -119,7 +119,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_null_island');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_linguistic_focus_null_island');
t.end();
});
@ -134,7 +134,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_full_address');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_full_address');
t.end();
});
@ -149,7 +149,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_partial_address');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_partial_address');
t.end();
});
@ -164,7 +164,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_regions_address');
t.deepEqual(compiled, expected, 'valid search query');
t.deepEqual(compiled, expected, 'search_regions_address');
t.end();
});

Loading…
Cancel
Save