From 139cb22127689a74dcd20a2a4a26f9ca12e0bd00 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Fri, 4 Sep 2015 18:03:28 -0400 Subject: [PATCH] Remove layers limiting on queries with few tokens Primarily as a performance optimization, but also to attempt to return more relevant results, only admin and POI layers were queried when the text input consisted of only one or two tokens, and there weren't any numbers. However as shown in #194 that is a bit too optimistic, mostly in contries other than the USA. Fixes #194 --- helper/query_parser.js | 3 --- test/unit/helper/query_parser.js | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/helper/query_parser.js b/helper/query_parser.js index d1c6672d..20e4c332 100644 --- a/helper/query_parser.js +++ b/helper/query_parser.js @@ -13,9 +13,6 @@ module.exports.get_layers = function get_layers(query) { if (query.length <= 3 ) { // no address parsing required return get_layers_helper(['admin']); - } else if (tokenized.length === 1 || (tokenized.length < 3 && !hasNumber)) { - // no need to hit address layers if there's only one (or two) token(s) - return get_layers_helper(['admin', 'poi']); } }; diff --git a/test/unit/helper/query_parser.js b/test/unit/helper/query_parser.js index 5cb84b83..1021d37c 100644 --- a/test/unit/helper/query_parser.js +++ b/test/unit/helper/query_parser.js @@ -63,6 +63,7 @@ module.exports.tests.parse_one_or_more_tokens = function(test, common) { var two_tokens_nonum = ['small town', 'biggg city', 'another empire']; var two_tokens_withnum= ['123 main', 'sixty 1', '123-980 house']; + // parse address is now always true to fix pelias/api#194 var testParse = function(query, parse_address) { test('query with one or more tokens (' + query + ')', function(t) { var address = parser.get_parsed_address(query); @@ -83,7 +84,7 @@ module.exports.tests.parse_one_or_more_tokens = function(test, common) { var queries = one_token_queries.concat(two_tokens_nonum); for (var key in queries) { - testParse( queries[key] ); + testParse( queries[key], true ); } for (key in two_tokens_withnum) { testParse( two_tokens_withnum[key], true );