diff --git a/controller/search.js b/controller/search.js index 7f7ffb689..35a5f0b5b 100644 --- a/controller/search.js +++ b/controller/search.js @@ -31,11 +31,6 @@ function setup( backend, query ){ body: query( req.clean ) }; - // use layers field for filtering by type - if( req.clean.hasOwnProperty('layers') ){ - cmd.type = req.clean.layers; - } - logger.debug( '[ES req]', cmd ); // query backend diff --git a/query/search.js b/query/search.js index 75406fe73..a6c2fd6a9 100644 --- a/query/search.js +++ b/query/search.js @@ -43,6 +43,7 @@ query.score( peliasQuery.view.admin_multi_match(adminFields, 'peliasAdmin') ); query.filter( peliasQuery.view.boundary_circle ); query.filter( peliasQuery.view.boundary_rect ); query.filter( peliasQuery.view.sources ); +query.filter( peliasQuery.view.layers ); // -------------------------------- /** @@ -59,6 +60,9 @@ function generateQuery( clean ){ // sources vs.var( 'sources', clean.sources); + // layers + vs.var( 'layers', clean.layers); + // size if( clean.querySize ) { vs.var( 'size', clean.querySize ); diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index 6af4e840e..94f867b24 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -81,7 +81,16 @@ module.exports = { 'weight': 2 }] } - }] + }], + 'filter': [ + { + 'terms': { + 'layer': [ + 'test' + ] + } + } + ] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_full_address.js b/test/unit/fixture/search_full_address.js index 6af4b35b2..d6a1478e9 100644 --- a/test/unit/fixture/search_full_address.js +++ b/test/unit/fixture/search_full_address.js @@ -128,7 +128,23 @@ module.exports = { 'query': 'new york', 'analyzer': 'peliasAdmin' } - }] + }], + 'filter': [ + { + 'terms': { + 'layer': [ + 'address', + 'venue', + 'country', + 'region', + 'county', + 'neighbourhood', + 'locality', + 'localadmin' + ] + } + } + ] } }, 'size': 10, diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 0a8f5ddce..b8dbf3a12 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -74,14 +74,21 @@ module.exports = { }], 'filter': [{ 'geo_bounding_box': { + 'type': 'indexed', 'center_point': { 'top': 11.51, 'right': -61.84, 'bottom': 47.47, 'left': -103.16 - }, - 'type': 'indexed' - } + } + } + }, + { + 'terms': { + 'layer': [ + 'test' + ] + } }] } }, diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index e3c027c1c..382732735 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -101,7 +101,16 @@ module.exports = { 'weight': 2 }] } - }] + }], + 'filter': [ + { + 'terms': { + 'layer': [ + 'test' + ] + } + } + ] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index a185ea733..ebc5f7015 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -104,13 +104,20 @@ module.exports = { }], 'filter': [{ 'geo_bounding_box': { + 'type': 'indexed', 'center_point': { 'top': 11.51, 'right': -61.84, 'bottom': 47.47, 'left': -103.16 - }, - 'type': 'indexed' + } + } + }, + { + 'terms': { + 'layer': [ + 'test' + ] } }] } diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index 152a0c42c..8f6fe3816 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -101,6 +101,13 @@ module.exports = { 'weight': 2 }] } + }], + 'filter':[{ + 'terms': { + 'layer': [ + 'test' + ] + } }] } }, diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index 2e820c80b..490eb0c96 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -71,7 +71,16 @@ module.exports = { 'weight': 2 }] } - }] + }], + 'filter': [ + { + 'terms': { + 'layer': [ + 'test' + ] + } + } + ] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_linguistic_viewport.js b/test/unit/fixture/search_linguistic_viewport.js index 4f225a626..ca6414a78 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -113,6 +113,15 @@ module.exports = { 'boost_mode': 'replace' } } + ], + 'filter': [ + { + 'terms': { + 'layer': [ + 'test' + ] + } + } ] } }, diff --git a/test/unit/fixture/search_partial_address.js b/test/unit/fixture/search_partial_address.js index ec8ff4ea6..10a2bb74e 100644 --- a/test/unit/fixture/search_partial_address.js +++ b/test/unit/fixture/search_partial_address.js @@ -96,7 +96,23 @@ module.exports = { 'query': 'new york', 'analyzer': 'peliasAdmin' } - }] + }], + 'filter': [ + { + 'terms': { + 'layer': [ + 'address', + 'venue', + 'country', + 'region', + 'county', + 'neighbourhood', + 'locality', + 'localadmin' + ] + } + } + ] } }, 'size': 10, diff --git a/test/unit/fixture/search_regions_address.js b/test/unit/fixture/search_regions_address.js index cf65b199c..400f561b7 100644 --- a/test/unit/fixture/search_regions_address.js +++ b/test/unit/fixture/search_regions_address.js @@ -112,7 +112,23 @@ module.exports = { 'query': 'manhattan', 'analyzer': 'peliasAdmin' } - }] + }], + 'filter': [ + { + 'terms': { + 'layer': [ + 'address', + 'venue', + 'country', + 'region', + 'county', + 'neighbourhood', + 'locality', + 'localadmin' + ] + } + } + ] } }, 'size': 10,