From 3df810e4c6d00ca36382eceec215697d35c8f204 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 15 Sep 2016 17:11:58 -0400 Subject: [PATCH 01/17] Require Node.js 4.0 or greater --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31c8d36f..787b224f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "url": "https://github.com/pelias/api/issues" }, "engines": { - "node": ">=0.10.26" + "node": ">=4.0.0" }, "dependencies": { "async": "^2.0.0", From b379af596991439091275a4abaa97e0e8a2e3e0e Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 15 Sep 2016 17:12:26 -0400 Subject: [PATCH 02/17] Remove Node.js 0.12 from TravisCI versions --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7c327439..b80c98ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ cache: notifications: email: false node_js: - - 0.12 - 4 - 6 matrix: From 11c3388b5773a3af9ce67b9a9f0c9dfa0757a6c5 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 15 Sep 2016 17:23:29 -0400 Subject: [PATCH 03/17] Add readme note about Node 4 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a28ceb52..2f6e6627 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ See the [Mapzen Search documentation](https://mapzen.com/documentation/search/). ## Install Dependencies +Note: Pelias requires Node.js v4 or newer + ```bash npm install ``` From f11873463f0ff37b07713e1645e9c5afbec25b33 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Mon, 10 Oct 2016 16:36:53 -0400 Subject: [PATCH 04/17] removed multicore support --- index.js | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/index.js b/index.js index 42116f53..e5404586 100644 --- a/index.js +++ b/index.js @@ -1,33 +1,7 @@ -var cluster = require('cluster'), - app = require('./app'), - port = ( process.env.PORT || 3100 ), - // when pelias/api#601 is done this can be changed to `true` - multicore = false; - -/** cluster webserver across all cores **/ -if( multicore ){ - - var numCPUs = require('os').cpus().length; - if( cluster.isMaster ){ - - // fork workers - for (var i = 0; i < numCPUs; i++) { - cluster.fork(); - } - - cluster.on('exit', function( worker, code, signal ){ - console.log('worker ' + worker.process.pid + ' died'); - }); - - } else { - app.listen( port ); - console.log( 'worker: listening on ' + port ); - } -} +var app = require('./app'), + port = ( process.env.PORT || 3100 ); /** run server on the default setup (single core) **/ -else { - console.log( 'listening on ' + port ); - app.listen( port ); -} +console.log( 'listening on ' + port ); +app.listen( port ); From 609c36d6cad8a2f0a658cc16dd937ab34d6a5d5c Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 3 Oct 2016 13:41:02 -0400 Subject: [PATCH 05/17] chore(package): update express-http-proxy to version 0.10.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 21600444..bd80bc3a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "elasticsearch": "^11.0.0", "elasticsearch-exceptions": "0.0.4", "express": "^4.8.8", - "express-http-proxy": "^0.7.0", + "express-http-proxy": "^0.10.0", "extend": "3.0.0", "geojson": "^0.4.0", "geojson-extent": "^0.3.1", From 3fe113645f1805564bb1bf8085b709644455947f Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Thu, 13 Oct 2016 16:45:24 -0400 Subject: [PATCH 06/17] feat: check for preferred record when dupe found --- middleware/dedupe.js | 49 ++++++++++++- test/unit/middleware/dedupe.js | 130 +++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 2 deletions(-) diff --git a/middleware/dedupe.js b/middleware/dedupe.js index b40f1806..03082710 100644 --- a/middleware/dedupe.js +++ b/middleware/dedupe.js @@ -16,11 +16,41 @@ function dedupeResults(req, res, next) { var uniqueResults = []; _.some(res.data, function (hit) { - if (uniqueResults.length === 0 || _.every(uniqueResults, isDifferent.bind(null, hit)) ) { + + if (_.isEmpty(uniqueResults)) { uniqueResults.push(hit); } else { - logger.info('[dupe]', { query: req.clean.text, hit: hit.name.default + ' ' + hit.source + ':' + hit._id }); + // if there are multiple items in results, loop through them to find a dupe + // save off the index of the dupe if found + var dupeIndex = uniqueResults.findIndex(function (elem, index, array) { + return !isDifferent(elem, hit); + }); + + // if a dupe is not found, just add to results and move on + if (dupeIndex === -1) { + uniqueResults.push(hit); + } + // if dupe was found, we need to check which of the records is preferred + // since the order in which Elasticsearch returns identical text matches is arbitrary + // of course, if the new one is preferred we should replace previous with new + else if (isPreferred(uniqueResults[dupeIndex], hit)) { + logger.info('[dupe][replacing]', { + query: req.clean.text, + previous: uniqueResults[dupeIndex].source, + hit: hit.name.default + ' ' + hit.source + ':' + hit._id + }); + // replace previous dupe item with current hit + uniqueResults.splice(dupeIndex, 1, hit); + } + // if not preferred over existing, just log and move on + else { + logger.info('[dupe][skipping]', { + query: req.clean.text, + previous: uniqueResults[dupeIndex].source, + hit: hit.name.default + ' ' + hit.source + ':' + hit._id + }); + } } // stop looping when requested size has been reached in uniqueResults @@ -32,4 +62,19 @@ function dedupeResults(req, res, next) { next(); } +function isPreferred(existing, candidateReplacement) { + // NOTE: we are assuming here that the layer for both records is the same + + //bind the trumps function to the data items to keep the rest of the function clean + var trumpsFunc = trumps.bind(null, existing, candidateReplacement); + + return trumpsFunc('geonames', 'whosonfirst') || // WOF has bbox and is generally preferred + trumpsFunc('openstreetmap', 'openaddresses') || // addresses are better in OA + trumpsFunc('whosonfirst', 'openstreetmap'); // venues are better in OSM, at this time +} + +function trumps(existing, candidateReplacement, loserSource, winnerSource) { + return existing.source === loserSource && candidateReplacement.source === winnerSource; +} + module.exports = setup; diff --git a/test/unit/middleware/dedupe.js b/test/unit/middleware/dedupe.js index b8100955..291d404a 100644 --- a/test/unit/middleware/dedupe.js +++ b/test/unit/middleware/dedupe.js @@ -58,6 +58,136 @@ module.exports.tests.dedupe = function(test, common) { }); }; +module.exports.tests.trump = function(test, common) { + test('whosonfirst trumps geonames, replace', function (t) { + var req = { + clean: { + text: 'Lancaster', + size: 100 + } + }; + var res = { + data: [ + { + 'name': { 'default': 'Lancaster' }, + 'source': 'geonames', + 'source_id': '123456', + 'layer': 'locality' + }, + { + 'name': { 'default': 'Lancaster' }, + 'source': 'whosonfirst', + 'source_id': '654321', + 'layer': 'locality' + } + ] + }; + + var expectedCount = 1; + dedupe(req, res, function () { + t.equal(res.data.length, expectedCount, 'results have fewer items than before'); + t.deepEqual(res.data[0].source, 'whosonfirst', 'whosonfirst result won'); + t.end(); + }); + }); + + test('whosonfirst trumps geonames, no replace', function (t) { + var req = { + clean: { + text: 'Lancaster', + size: 100 + } + }; + var res = { + data: [ + { + 'name': { 'default': 'Lancaster' }, + 'source': 'whosonfirst', + 'source_id': '123456', + 'layer': 'locality' + }, + { + 'name': { 'default': 'Lancaster' }, + 'source': 'geonames', + 'source_id': '654321', + 'layer': 'locality' + } + ] + }; + + var expectedCount = 1; + dedupe(req, res, function () { + t.equal(res.data.length, expectedCount, 'results have fewer items than before'); + t.deepEqual(res.data[0].source, 'whosonfirst', 'whosonfirst result won'); + t.end(); + }); + }); + + test('openstreetmap trumps whosonfirst venues', function (t) { + var req = { + clean: { + text: 'Lancaster Dairy Farm', + size: 100 + } + }; + var res = { + data: [ + { + 'name': { 'default': 'Lancaster Dairy Farm' }, + 'source': 'openstreetmap', + 'source_id': '123456', + 'layer': 'venue' + }, + { + 'name': { 'default': 'Lancaster Dairy Farm' }, + 'source': 'whosonfirst', + 'source_id': '654321', + 'layer': 'venue' + } + ] + }; + + var expectedCount = 1; + dedupe(req, res, function () { + t.equal(res.data.length, expectedCount, 'results have fewer items than before'); + t.deepEqual(res.data[0].source, 'openstreetmap', 'openstreetmap result won'); + t.end(); + }); + }); + + test('openaddresses trumps openstreetmap', function (t) { + var req = { + clean: { + text: '100 Main St', + size: 100 + } + }; + var res = { + data: [ + { + 'name': { 'default': '100 Main St' }, + 'source': 'openstreetmap', + 'source_id': '123456', + 'layer': 'address' + }, + { + 'name': { 'default': '100 Main St' }, + 'source': 'openaddresses', + 'source_id': '654321', + 'layer': 'address' + } + ] + }; + + var expectedCount = 1; + dedupe(req, res, function () { + t.equal(res.data.length, expectedCount, 'results have fewer items than before'); + t.deepEqual(res.data[0].source, 'openaddresses', 'openaddresses result won'); + t.end(); + }); + }); +}; + module.exports.all = function (tape, common) { function test(name, testFunction) { From 24aadbe4a20fb449d667f020a8055d645e4bf950 Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Thu, 13 Oct 2016 19:31:23 -0400 Subject: [PATCH 07/17] fix: increment geocodejson format version number in results --- middleware/geocodeJSON.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/geocodeJSON.js b/middleware/geocodeJSON.js index 3b5170dd..442e017e 100644 --- a/middleware/geocodeJSON.js +++ b/middleware/geocodeJSON.js @@ -43,7 +43,7 @@ function convertToGeocodeJSON(req, res, next, opts) { // REQUIRED. A semver.org compliant version number. Describes the version of // the GeocodeJSON spec that is implemented by this instance. - res.body.geocoding.version = '0.1'; + res.body.geocoding.version = '0.2'; // OPTIONAL. Default: null. The attribution of the data. In case of multiple sources, // and then multiple attributions, can be an object with one key by source. From 1ee0a75c1698c913912ba78b84d274bcc8492d4c Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 17 Oct 2016 12:34:07 -0400 Subject: [PATCH 08/17] chore(package): update pelias-config to version 2.3.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd80bc3a..299f5129 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "markdown": "0.5.0", "morgan": "1.7.0", "pelias-categories": "1.0.0", - "pelias-config": "2.1.0", + "pelias-config": "2.3.0", "pelias-logger": "0.0.8", "pelias-model": "4.2.0", "pelias-query": "8.6.0", From 3aa80c7d1fbecc640adaa72a985759c333048744 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 17 Oct 2016 13:34:24 -0400 Subject: [PATCH 09/17] chore(package): update pelias-logger to version 0.1.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 299f5129..874474cd 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "morgan": "1.7.0", "pelias-categories": "1.0.0", "pelias-config": "2.3.0", - "pelias-logger": "0.0.8", + "pelias-logger": "0.1.0", "pelias-model": "4.2.0", "pelias-query": "8.6.0", "pelias-text-analyzer": "1.3.0", From 6fc5a19461b112a9da020f91755884fd659f9ab2 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 17 Oct 2016 14:45:40 -0400 Subject: [PATCH 10/17] chore(package): update pelias-model to version 4.3.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 874474cd..86ec8655 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "pelias-categories": "1.0.0", "pelias-config": "2.3.0", "pelias-logger": "0.1.0", - "pelias-model": "4.2.0", + "pelias-model": "4.3.0", "pelias-query": "8.6.0", "pelias-text-analyzer": "1.3.0", "stats-lite": "2.0.3", From 2631d8567695e553544837d8d3805f5db1dd970d Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 17 Oct 2016 14:45:46 -0400 Subject: [PATCH 11/17] chore(package): update pelias-text-analyzer to version 1.4.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 874474cd..6ca92a60 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "pelias-logger": "0.1.0", "pelias-model": "4.2.0", "pelias-query": "8.6.0", - "pelias-text-analyzer": "1.3.0", + "pelias-text-analyzer": "1.4.0", "stats-lite": "2.0.3", "through2": "2.0.1" }, From a3fa49ee52d5ceec5164e5793102acdfcac3a56f Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Mon, 17 Oct 2016 15:09:58 -0400 Subject: [PATCH 12/17] remove splice and replace with direct assignment --- middleware/dedupe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/dedupe.js b/middleware/dedupe.js index 03082710..3b125d0d 100644 --- a/middleware/dedupe.js +++ b/middleware/dedupe.js @@ -41,7 +41,7 @@ function dedupeResults(req, res, next) { hit: hit.name.default + ' ' + hit.source + ':' + hit._id }); // replace previous dupe item with current hit - uniqueResults.splice(dupeIndex, 1, hit); + uniqueResults[dupeIndex] = hit; } // if not preferred over existing, just log and move on else { From 0c7fbdbabaf32190c4d3328812af9f6093fe1af0 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 17 Oct 2016 16:07:44 -0400 Subject: [PATCH 13/17] chore(package): update pelias-categories to version 1.1.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d007831..9fcb407e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "lodash": "^4.5.0", "markdown": "0.5.0", "morgan": "1.7.0", - "pelias-categories": "1.0.0", + "pelias-categories": "1.1.0", "pelias-config": "2.3.0", "pelias-logger": "0.1.0", "pelias-model": "4.3.0", From 92e771d68c5d45a8e65f1699e9e49ef61159219f Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 17 Oct 2016 16:26:54 -0400 Subject: [PATCH 14/17] chore(package): update pelias-query to version 8.7.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fcb407e..85e3e594 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "pelias-config": "2.3.0", "pelias-logger": "0.1.0", "pelias-model": "4.3.0", - "pelias-query": "8.6.0", + "pelias-query": "8.7.0", "pelias-text-analyzer": "1.4.0", "stats-lite": "2.0.3", "through2": "2.0.1" From 8827c98e05d111277881d898147df0987760ee0d Mon Sep 17 00:00:00 2001 From: Amir Rahnama Date: Tue, 18 Oct 2016 11:46:43 +0200 Subject: [PATCH 15/17] Update Dockerfile to avoid npm install fail --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5b07acd6..a90bda50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:0.12 +FROM node:4.6.0 MAINTAINER Pelias EXPOSE 3100 From 7555095399f882c29034e0cc0c6d341dce9d4fc9 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Wed, 19 Oct 2016 13:48:00 -0400 Subject: [PATCH 16/17] added `boost:address` and `boost:street` to search defaults bumped query version to 8.8.0 defaults are `10` and `5`, respectively --- package.json | 2 +- query/search_defaults.js | 5 ++++- test/unit/fixture/search_boundary_country.js | 11 +---------- test/unit/fixture/search_fallback.js | 12 ++---------- test/unit/fixture/search_linguistic_bbox.js | 11 +---------- test/unit/fixture/search_linguistic_focus.js | 11 +---------- test/unit/fixture/search_linguistic_focus_bbox.js | 11 +---------- .../fixture/search_linguistic_focus_null_island.js | 11 +---------- test/unit/fixture/search_linguistic_only.js | 11 +---------- test/unit/fixture/search_linguistic_viewport.js | 11 +---------- .../search_linguistic_viewport_min_diagonal.js | 11 +---------- test/unit/fixture/search_with_category_filtering.js | 11 +---------- test/unit/fixture/search_with_source_filtering.js | 11 +---------- 13 files changed, 17 insertions(+), 112 deletions(-) diff --git a/package.json b/package.json index 85e3e594..0443f632 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "pelias-config": "2.3.0", "pelias-logger": "0.1.0", "pelias-model": "4.3.0", - "pelias-query": "8.7.0", + "pelias-query": "8.8.0", "pelias-text-analyzer": "1.4.0", "stats-lite": "2.0.3", "through2": "2.0.1" diff --git a/query/search_defaults.js b/query/search_defaults.js index 4e6a7ffb..c0d2a6a0 100644 --- a/query/search_defaults.js +++ b/query/search_defaults.js @@ -92,6 +92,9 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'population:field': 'population', 'population:modifier': 'log1p', 'population:max_boost': 20, - 'population:weight': 2 + 'population:weight': 2, + + 'boost:address': 10, + 'boost:street': 5 }); diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index f622e1f5..ba99a72a 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -76,16 +77,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_fallback.js b/test/unit/fixture/search_fallback.js index f7983da9..857e47e9 100644 --- a/test/unit/fixture/search_fallback.js +++ b/test/unit/fixture/search_fallback.js @@ -98,6 +98,7 @@ module.exports = { { 'bool': { '_name': 'fallback.address', + 'boost': 10, 'must': [ { 'match_phrase': { @@ -195,6 +196,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -790,16 +792,6 @@ module.exports = { 'size': 20, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 52c73c3c..93d2a804 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -79,16 +80,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index 33c62c1e..aeda6ba2 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -82,16 +83,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index 717c27ac..335c9ad3 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -93,16 +94,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index 20f72ceb..e1416526 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -82,16 +83,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index 8c377f71..1f1479a3 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -68,16 +69,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_linguistic_viewport.js b/test/unit/fixture/search_linguistic_viewport.js index 8c377f71..1f1479a3 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -68,16 +69,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js index 8c377f71..1f1479a3 100644 --- a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js +++ b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -68,16 +69,6 @@ module.exports = { 'size': 50, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_with_category_filtering.js b/test/unit/fixture/search_with_category_filtering.js index 9913b19c..05f9ec4e 100644 --- a/test/unit/fixture/search_with_category_filtering.js +++ b/test/unit/fixture/search_with_category_filtering.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -69,16 +70,6 @@ module.exports = { 'size': 20, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; diff --git a/test/unit/fixture/search_with_source_filtering.js b/test/unit/fixture/search_with_source_filtering.js index 78889325..0e9010c2 100644 --- a/test/unit/fixture/search_with_source_filtering.js +++ b/test/unit/fixture/search_with_source_filtering.js @@ -9,6 +9,7 @@ module.exports = { { 'bool': { '_name': 'fallback.street', + 'boost': 5, 'must': [ { 'match_phrase': { @@ -68,16 +69,6 @@ module.exports = { 'size': 20, 'track_scores': true, 'sort': [ - { - 'population': { - 'order': 'desc' - } - }, - { - 'popularity': { - 'order': 'desc' - } - }, '_score' ] }; From 4dbaff6589d153525803e8387274269265336866 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Wed, 19 Oct 2016 14:24:34 -0400 Subject: [PATCH 17/17] removed hard-coded `size` effectively reverts https://github.com/pelias/api/pull/684 --- query/search.js | 2 +- test/unit/fixture/search_boundary_country.js | 2 +- test/unit/fixture/search_linguistic_bbox.js | 2 +- test/unit/fixture/search_linguistic_focus.js | 2 +- test/unit/fixture/search_linguistic_focus_bbox.js | 2 +- test/unit/fixture/search_linguistic_focus_null_island.js | 2 +- test/unit/fixture/search_linguistic_only.js | 2 +- test/unit/fixture/search_linguistic_viewport.js | 2 +- test/unit/fixture/search_linguistic_viewport_min_diagonal.js | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/query/search.js b/query/search.js index 29dea8b9..bed5a63c 100644 --- a/query/search.js +++ b/query/search.js @@ -59,7 +59,7 @@ function generateQuery( clean ){ // size if( clean.querySize ) { - vs.var( 'size', 50 ); + vs.var( 'size', clean.querySize ); } // focus point diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index ba99a72a..ee6427a0 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -74,7 +74,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score' diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 93d2a804..e74f6c79 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -77,7 +77,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score' diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index aeda6ba2..a63400b3 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -80,7 +80,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score' diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index 335c9ad3..7f6c8528 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -91,7 +91,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score' diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index e1416526..da12154a 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -80,7 +80,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score' diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index 1f1479a3..0117e03b 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -66,7 +66,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score' diff --git a/test/unit/fixture/search_linguistic_viewport.js b/test/unit/fixture/search_linguistic_viewport.js index 1f1479a3..0117e03b 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -66,7 +66,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score' diff --git a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js index 1f1479a3..0117e03b 100644 --- a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js +++ b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js @@ -66,7 +66,7 @@ module.exports = { 'boost_mode': 'multiply' } }, - 'size': 50, + 'size': 10, 'track_scores': true, 'sort': [ '_score'