From d68246809677a2fde085dc3834fe61b0329cfd36 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Sun, 21 Aug 2016 21:47:27 -0400 Subject: [PATCH] adapted tests to latest query module output --- test/unit/fixture/search_fallback.js | 170 +++++++++++++++++- test/unit/fixture/search_geodisambiguation.js | 57 ++++++ 2 files changed, 220 insertions(+), 7 deletions(-) diff --git a/test/unit/fixture/search_fallback.js b/test/unit/fixture/search_fallback.js index 304841b5..96565e0e 100644 --- a/test/unit/fixture/search_fallback.js +++ b/test/unit/fixture/search_fallback.js @@ -47,6 +47,18 @@ module.exports = { ] } }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, { 'multi_match': { 'query': 'state value', @@ -63,7 +75,9 @@ module.exports = { 'type': 'phrase', 'fields': [ 'parent.country', - 'parent.country_a' + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' ] } } @@ -121,6 +135,18 @@ module.exports = { ] } }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, { 'multi_match': { 'query': 'state value', @@ -137,7 +163,9 @@ module.exports = { 'type': 'phrase', 'fields': [ 'parent.country', - 'parent.country_a' + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' ] } } @@ -185,6 +213,18 @@ module.exports = { ] } }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, { 'multi_match': { 'query': 'state value', @@ -201,7 +241,9 @@ module.exports = { 'type': 'phrase', 'fields': [ 'parent.country', - 'parent.country_a' + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' ] } } @@ -239,6 +281,18 @@ module.exports = { ] } }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, { 'multi_match': { 'query': 'state value', @@ -255,7 +309,9 @@ module.exports = { 'type': 'phrase', 'fields': [ 'parent.country', - 'parent.country_a' + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' ] } } @@ -281,6 +337,18 @@ module.exports = { ] } }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, { 'multi_match': { 'query': 'state value', @@ -297,7 +365,9 @@ module.exports = { 'type': 'phrase', 'fields': [ 'parent.country', - 'parent.country_a' + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' ] } } @@ -309,6 +379,52 @@ module.exports = { } } }, + { + 'bool': { + '_name': 'fallback.county', + 'must': [ + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'county' + } + } + } + }, { 'bool': { '_name': 'fallback.region', @@ -329,7 +445,9 @@ module.exports = { 'type': 'phrase', 'fields': [ 'parent.country', - 'parent.country_a' + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' ] } } @@ -351,7 +469,9 @@ module.exports = { 'type': 'phrase', 'fields': [ 'parent.country', - 'parent.country_a' + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' ] } } @@ -362,6 +482,42 @@ module.exports = { } } } + }, + { + 'function_score': { + 'query': null, + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + } + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } + }, + { + 'function_score': { + 'query': null, + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 + } + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } } ] } diff --git a/test/unit/fixture/search_geodisambiguation.js b/test/unit/fixture/search_geodisambiguation.js index bd81e237..c0784252 100644 --- a/test/unit/fixture/search_geodisambiguation.js +++ b/test/unit/fixture/search_geodisambiguation.js @@ -170,6 +170,27 @@ module.exports = { } } }, + { + 'bool': { + 'must': [ + { + 'multi_match': { + 'query': 'neighbourhood value', + 'type': 'phrase', + 'fields': [ + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'dependency' + } + } + } + }, { 'bool': { 'must': [ @@ -190,6 +211,42 @@ module.exports = { } } } + }, + { + 'function_score': { + 'query': null, + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + } + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } + }, + { + 'function_score': { + 'query': null, + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 + } + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } } ] }