Browse Source

updated naming from component to structured

pull/740/head
Stephen Hess 8 years ago
parent
commit
be2a336038
  1. 0
      middleware/trimByGranularityStructured.js
  2. 22
      query/structured_geocoding.js
  3. 16
      routes/v1.js
  4. 0
      sanitizer/structured_geocoding.js
  5. 0
      test/unit/fixture/structured_geocoding/boundary_country.json
  6. 0
      test/unit/fixture/structured_geocoding/fallback.json
  7. 0
      test/unit/fixture/structured_geocoding/linguistic_bbox.json
  8. 0
      test/unit/fixture/structured_geocoding/linguistic_focus.json
  9. 0
      test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json
  10. 0
      test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json
  11. 0
      test/unit/fixture/structured_geocoding/linguistic_only.json
  12. 0
      test/unit/fixture/structured_geocoding/linguistic_viewport.json
  13. 0
      test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json
  14. 0
      test/unit/fixture/structured_geocoding/with_source_filtering.json
  15. 2
      test/unit/middleware/trimByGranularityStructured.js
  16. 24
      test/unit/query/structured_geocoding.js
  17. 6
      test/unit/run.js
  18. 4
      test/unit/sanitizer/structured_geocoding.js

0
middleware/trimByGranularityComponent.js → middleware/trimByGranularityStructured.js

22
query/component_geocoding.js → query/structured_geocoding.js

@ -6,21 +6,21 @@ var peliasQuery = require('pelias-query'),
//------------------------------ //------------------------------
// general-purpose search query // general-purpose search query
//------------------------------ //------------------------------
var componentQuery = new peliasQuery.layout.ComponentFallbackQuery(); var structuredQuery = new peliasQuery.layout.ComponentFallbackQuery();
// scoring boost // scoring boost
componentQuery.score( peliasQuery.view.focus_only_function( peliasQuery.view.phrase ) ); structuredQuery.score( peliasQuery.view.focus_only_function( peliasQuery.view.phrase ) );
componentQuery.score( peliasQuery.view.popularity_only_function ); structuredQuery.score( peliasQuery.view.popularity_only_function );
componentQuery.score( peliasQuery.view.population_only_function ); structuredQuery.score( peliasQuery.view.population_only_function );
// -------------------------------- // --------------------------------
// non-scoring hard filters // non-scoring hard filters
componentQuery.filter( peliasQuery.view.boundary_country ); structuredQuery.filter( peliasQuery.view.boundary_country );
componentQuery.filter( peliasQuery.view.boundary_circle ); structuredQuery.filter( peliasQuery.view.boundary_circle );
componentQuery.filter( peliasQuery.view.boundary_rect ); structuredQuery.filter( peliasQuery.view.boundary_rect );
componentQuery.filter( peliasQuery.view.sources ); structuredQuery.filter( peliasQuery.view.sources );
componentQuery.filter( peliasQuery.view.layers ); structuredQuery.filter( peliasQuery.view.layers );
componentQuery.filter( peliasQuery.view.categories ); structuredQuery.filter( peliasQuery.view.categories );
// -------------------------------- // --------------------------------
/** /**
@ -105,7 +105,7 @@ function generateQuery( clean ){
function getQuery(vs) { function getQuery(vs) {
return { return {
type: 'fallback', type: 'fallback',
body: componentQuery.render(vs) body: structuredQuery.render(vs)
}; };
} }

16
routes/v1.js

@ -8,7 +8,7 @@ var sanitizers = {
place: require('../sanitizer/place'), place: require('../sanitizer/place'),
search: require('../sanitizer/search'), search: require('../sanitizer/search'),
search_fallback: require('../sanitizer/search_fallback'), search_fallback: require('../sanitizer/search_fallback'),
component_geocoding: require('../sanitizer/component_geocoding'), structured_geocoding: require('../sanitizer/structured_geocoding'),
reverse: require('../sanitizer/reverse'), reverse: require('../sanitizer/reverse'),
nearby: require('../sanitizer/nearby') nearby: require('../sanitizer/nearby')
}; };
@ -30,14 +30,14 @@ var controllers = {
var queries = { var queries = {
libpostal: require('../query/search'), libpostal: require('../query/search'),
fallback_to_old_prod: require('../query/search_original'), fallback_to_old_prod: require('../query/search_original'),
component_geocoding: require('../query/component_geocoding') structured_geocoding: require('../query/structured_geocoding')
}; };
/** ----------------------- controllers ----------------------- **/ /** ----------------------- controllers ----------------------- **/
var postProc = { var postProc = {
trimByGranularity: require('../middleware/trimByGranularity'), trimByGranularity: require('../middleware/trimByGranularity'),
trimByGranularityComponent: require('../middleware/trimByGranularityComponent'), trimByGranularityStructured: require('../middleware/trimByGranularityStructured'),
distances: require('../middleware/distance'), distances: require('../middleware/distance'),
confidenceScores: require('../middleware/confidenceScore'), confidenceScores: require('../middleware/confidenceScore'),
confidenceScoresFallback: require('../middleware/confidenceScoreFallback'), confidenceScoresFallback: require('../middleware/confidenceScoreFallback'),
@ -95,11 +95,11 @@ function addRoutes(app, peliasConfig) {
postProc.geocodeJSON(peliasConfig, base), postProc.geocodeJSON(peliasConfig, base),
postProc.sendJSON postProc.sendJSON
]), ]),
component: createRouter([ structured: createRouter([
sanitizers.component_geocoding.middleware, sanitizers.structured_geocoding.middleware,
middleware.calcSize(), middleware.calcSize(),
controllers.search(peliasConfig, undefined, queries.component_geocoding), controllers.search(peliasConfig, undefined, queries.structured_geocoding),
postProc.trimByGranularityComponent(), postProc.trimByGranularityStructured(),
postProc.distances('focus.point.'), postProc.distances('focus.point.'),
postProc.confidenceScores(peliasConfig), postProc.confidenceScores(peliasConfig),
postProc.confidenceScoresFallback(), postProc.confidenceScoresFallback(),
@ -193,7 +193,7 @@ function addRoutes(app, peliasConfig) {
app.get ( base + 'autocomplete', routers.autocomplete ); app.get ( base + 'autocomplete', routers.autocomplete );
app.get ( base + 'search', routers.search ); app.get ( base + 'search', routers.search );
app.post( base + 'search', routers.search ); app.post( base + 'search', routers.search );
app.get ( base + 'beta/component', routers.component ); app.get ( base + 'search/structured', routers.structured );
app.get ( base + 'reverse', routers.reverse ); app.get ( base + 'reverse', routers.reverse );
app.get ( base + 'nearby', routers.nearby ); app.get ( base + 'nearby', routers.nearby );

0
sanitizer/component_geocoding.js → sanitizer/structured_geocoding.js

0
test/unit/fixture/component_geocoding/boundary_country.json → test/unit/fixture/structured_geocoding/boundary_country.json

0
test/unit/fixture/component_geocoding/fallback.json → test/unit/fixture/structured_geocoding/fallback.json

0
test/unit/fixture/component_geocoding/linguistic_bbox.json → test/unit/fixture/structured_geocoding/linguistic_bbox.json

0
test/unit/fixture/component_geocoding/linguistic_focus.json → test/unit/fixture/structured_geocoding/linguistic_focus.json

0
test/unit/fixture/component_geocoding/linguistic_focus_bbox.json → test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json

0
test/unit/fixture/component_geocoding/linguistic_focus_null_island.json → test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json

0
test/unit/fixture/component_geocoding/linguistic_only.json → test/unit/fixture/structured_geocoding/linguistic_only.json

0
test/unit/fixture/component_geocoding/linguistic_viewport.json → test/unit/fixture/structured_geocoding/linguistic_viewport.json

0
test/unit/fixture/component_geocoding/linguistic_viewport_min_diagonal.json → test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json

0
test/unit/fixture/component_geocoding/with_source_filtering.json → test/unit/fixture/structured_geocoding/with_source_filtering.json

2
test/unit/middleware/trimByGranularityComponent.js → test/unit/middleware/trimByGranularityStructured.js

@ -1,4 +1,4 @@
var trimByGranularity = require('../../../middleware/trimByGranularityComponent')(); var trimByGranularity = require('../../../middleware/trimByGranularityStructured')();
module.exports.tests = {}; module.exports.tests = {};

24
test/unit/query/component_geocoding.js → test/unit/query/structured_geocoding.js

@ -1,4 +1,4 @@
var generate = require('../../../query/component_geocoding'); var generate = require('../../../query/structured_geocoding');
var fs = require('fs'); var fs = require('fs');
module.exports.tests = {}; module.exports.tests = {};
@ -28,7 +28,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/linguistic_focus_bbox'); var expected = require('../fixture/structured_geocoding/linguistic_focus_bbox');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_bbox'); t.deepEqual(compiled.body, expected, 'search_linguistic_focus_bbox');
@ -51,7 +51,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/linguistic_bbox'); var expected = require('../fixture/structured_geocoding/linguistic_bbox');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_bbox'); t.deepEqual(compiled.body, expected, 'search_linguistic_bbox');
@ -69,7 +69,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/linguistic_only'); var expected = require('../fixture/structured_geocoding/linguistic_only');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_only'); t.deepEqual(compiled.body, expected, 'search_linguistic_only');
@ -88,7 +88,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/linguistic_focus'); var expected = require('../fixture/structured_geocoding/linguistic_focus');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus'); t.deepEqual(compiled.body, expected, 'search_linguistic_focus');
@ -110,7 +110,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/linguistic_viewport'); var expected = require('../fixture/structured_geocoding/linguistic_viewport');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_viewport'); t.deepEqual(compiled.body, expected, 'search_linguistic_viewport');
@ -134,7 +134,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/linguistic_viewport_min_diagonal'); var expected = require('../fixture/structured_geocoding/linguistic_viewport_min_diagonal');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'valid search query'); t.deepEqual(compiled.body, expected, 'valid search query');
@ -153,7 +153,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/linguistic_focus_null_island'); var expected = require('../fixture/structured_geocoding/linguistic_focus_null_island');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_null_island'); t.deepEqual(compiled.body, expected, 'search_linguistic_focus_null_island');
@ -180,7 +180,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse(JSON.stringify(query)); var compiled = JSON.parse(JSON.stringify(query));
var expected = require('../fixture/component_geocoding/fallback'); var expected = require('../fixture/structured_geocoding/fallback');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'fallbackQuery'); t.deepEqual(compiled.body, expected, 'fallbackQuery');
@ -200,7 +200,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/boundary_country'); var expected = require('../fixture/structured_geocoding/boundary_country');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search: valid boundary.country query'); t.deepEqual(compiled.body, expected, 'search: valid boundary.country query');
@ -218,7 +218,7 @@ module.exports.tests.query = function(test, common) {
var query = generate(clean); var query = generate(clean);
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/component_geocoding/with_source_filtering'); var expected = require('../fixture/structured_geocoding/with_source_filtering');
t.deepEqual(compiled.type, 'fallback', 'query type set'); t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'search: valid search query with source filtering'); t.deepEqual(compiled.body, expected, 'search: valid search query with source filtering');
@ -229,7 +229,7 @@ module.exports.tests.query = function(test, common) {
module.exports.all = function (tape, common) { module.exports.all = function (tape, common) {
function test(name, testFunction) { function test(name, testFunction) {
return tape('component_geocoding query ' + name, testFunction); return tape('structured_geocoding query ' + name, testFunction);
} }
for( var testCase in module.exports.tests ){ for( var testCase in module.exports.tests ){

6
test/unit/run.js

@ -30,15 +30,15 @@ var tests = [
require('./middleware/sendJSON'), require('./middleware/sendJSON'),
require('./middleware/normalizeParentIds'), require('./middleware/normalizeParentIds'),
require('./middleware/trimByGranularity'), require('./middleware/trimByGranularity'),
require('./middleware/trimByGranularityComponent'), require('./middleware/trimByGranularityStructured'),
require('./query/autocomplete'), require('./query/autocomplete'),
require('./query/autocomplete_defaults'), require('./query/autocomplete_defaults'),
require('./query/component_geocoding'),
require('./query/search_defaults'), require('./query/search_defaults'),
require('./query/reverse_defaults'), require('./query/reverse_defaults'),
require('./query/reverse'), require('./query/reverse'),
require('./query/search'), require('./query/search'),
require('./query/search_original'), require('./query/search_original'),
require('./query/structured_geocoding'),
require('./query/text_parser'), require('./query/text_parser'),
require('./sanitizer/_boundary_country'), require('./sanitizer/_boundary_country'),
require('./sanitizer/_flag_bool'), require('./sanitizer/_flag_bool'),
@ -61,7 +61,7 @@ var tests = [
require('./sanitizer/nearby'), require('./sanitizer/nearby'),
require('./src/backend'), require('./src/backend'),
require('./sanitizer/autocomplete'), require('./sanitizer/autocomplete'),
require('./sanitizer/component_geocoding'), require('./sanitizer/structured_geocoding'),
require('./sanitizer/place'), require('./sanitizer/place'),
require('./sanitizer/reverse'), require('./sanitizer/reverse'),
require('./sanitizer/sanitizeAll'), require('./sanitizer/sanitizeAll'),

4
test/unit/sanitizer/component_geocoding.js → test/unit/sanitizer/structured_geocoding.js

@ -8,7 +8,7 @@ module.exports.tests.sanitize = function(test, common) {
// rather than re-verify the functionality of all the sanitizers, this test just verifies that they // rather than re-verify the functionality of all the sanitizers, this test just verifies that they
// were all called correctly // were all called correctly
var search = proxyquire('../../../sanitizer/component_geocoding', { var search = proxyquire('../../../sanitizer/structured_geocoding', {
'../sanitizer/_deprecate_quattroshapes': function() { '../sanitizer/_deprecate_quattroshapes': function() {
called_sanitizers.push('_deprecate_quattroshapes'); called_sanitizers.push('_deprecate_quattroshapes');
return { errors: [], warnings: [] }; return { errors: [], warnings: [] };
@ -109,7 +109,7 @@ module.exports.tests.sanitize = function(test, common) {
module.exports.all = function (tape, common) { module.exports.all = function (tape, common) {
function test(name, testFunction) { function test(name, testFunction) {
return tape('SANTIZE /component ' + name, testFunction); return tape('SANTIZE /structured ' + name, testFunction);
} }
for( var testCase in module.exports.tests ){ for( var testCase in module.exports.tests ){
Loading…
Cancel
Save