diff --git a/bin/middlewares/fullText_query.js b/bin/middlewares/fullText_query.js index dd1069b7e..80b050660 100644 --- a/bin/middlewares/fullText_query.js +++ b/bin/middlewares/fullText_query.js @@ -10,7 +10,7 @@ module.exports = function (config) { } const idunnBaseUrl = config.server.services.idunn.url || config.services.idunn.url; - const geocoderUrl = idunnBaseUrl + '/v1/autocomplete'; + const geocoderUrl = idunnBaseUrl + '/v1/search'; const useNlu = config.services.geocoder.useNlu; const categories = yaml.readSync('../../config/categories.yml'); diff --git a/tests/__data__/search_type.json b/tests/__data__/search_type.json new file mode 100644 index 000000000..b4ac3f327 --- /dev/null +++ b/tests/__data__/search_type.json @@ -0,0 +1,118 @@ +{ + "type": "FeatureCollection", + "geocoding": {"version": "0.1.0", "query": ""}, + "features": [ + { + "type": "Feature", + "geometry": { + "coordinates": [ + 4.359352, + 43.84274 + ], + "type": "Point" + }, + "properties": { + "geocoding": { + "id": "addr:4.359352;43.84274", + "type": "house", + "label": "37 Rue Robert (Nîmes)", + "name": "37 Rue Robert", + "housenumber": "37", + "street": "Rue Robert", + "postcode": "30000", + "city": "Nîmes", + "citycode": "30189", + "administrative_regions": [ + { + "id": "admin:osm:relation:2202162", + "insee": "", + "level": 2, + "label": "France", + "name": "France", + "zip_codes": [], + "weight": 0.015618298409952112, + "coord": { + "lon": 2.3514992, + "lat": 48.8566101 + }, + "bbox": [ + -5.4534286, + 41.2632185, + 9.8678344, + 51.268318 + ], + "admin_type": "Unknown", + "zone_type": "country" + }, + { + "id": "admin:osm:relation:3792883", + "insee": "76", + "level": 4, + "label": "Occitanie, France", + "name": "Occitanie", + "zip_codes": [], + "weight": 0.0030751822769848129, + "coord": { + "lon": 1.4442469, + "lat": 43.6044622 + }, + "bbox": [ + -0.3272334, + 42.3327551, + 4.8455335, + 45.0466382 + ], + "admin_type": "Unknown", + "zone_type": "state" + }, + { + "id": "admin:osm:relation:7461", + "insee": "30", + "level": 6, + "label": "Gard, Occitanie, France", + "name": "Gard", + "zip_codes": [], + "weight": 0.000989824164894286, + "coord": { + "lon": 4.3600687, + "lat": 43.8374249 + }, + "bbox": [ + 3.2618961, + 43.460197, + 4.8455335, + 44.4596601 + ], + "admin_type": "Unknown", + "zone_type": "state_district" + }, + { + "id": "admin:osm:relation:378685", + "insee": "30189", + "level": 8, + "label": "Nîmes (30000-30900), Gard, Occitanie, France", + "name": "Nîmes", + "zip_codes": [ + "30000", + "30900" + ], + "weight": 0.000989824164894286, + "coord": { + "lon": 4.3600687, + "lat": 43.8374249 + }, + "bbox": [ + 4.235670799999999, + 43.7412659, + 4.4496605, + 43.9230177 + ], + "admin_type": "City", + "zone_type": "city" + } + ] + } + } + } + ] +} diff --git a/tests/integration/server_start.js b/tests/integration/server_start.js index 872e44c71..3c4b72cd5 100644 --- a/tests/integration/server_start.js +++ b/tests/integration/server_start.js @@ -29,26 +29,26 @@ nock(/idunn_test\.test/) .get(/osm:way:2403/) .reply(404); -const noResultAutocomplete = require('../__data__/autocomplete_empty.json'); +const noResultSearch = require('../__data__/autocomplete_empty.json'); nock(/idunn_test\.test/) .persist(true) - .get('/v1/autocomplete') + .get('/v1/search') .query(params => params.q === 'gibberish') - .reply(200, JSON.stringify(noResultAutocomplete)); + .reply(200, JSON.stringify(noResultSearch)); -const intentionAutocomplete = require('../__data__/autocomplete_nlu.json'); +const intentionSearch = require('../__data__/autocomplete_nlu.json'); nock(/idunn_test\.test/) .persist(true) - .get('/v1/autocomplete') + .get('/v1/search') .query(params => params.q === 'restonice') - .reply(200, JSON.stringify(intentionAutocomplete)); + .reply(200, JSON.stringify(intentionSearch)); -const noIntentionAutocomplete = require('../__data__/autocomplete_type.json'); +const noIntentionSearch = require('../__data__/search_type.json'); nock(/idunn_test\.test/) .persist(true) - .get('/v1/autocomplete') + .get('/v1/search') .query(params => params.q === 'single') - .reply(200, JSON.stringify(noIntentionAutocomplete)); + .reply(200, JSON.stringify(noIntentionSearch)); global.appServer = new App(config); diff --git a/tests/integration/tests/server.js b/tests/integration/tests/server.js index f9d294806..fd922f182 100644 --- a/tests/integration/tests/server.js +++ b/tests/integration/tests/server.js @@ -163,7 +163,8 @@ describe('Full text queries (?q= param)', () => { .expect(res => { const redirectUrl = res.get('Location'); const [_, poiID] = /\/place\/([^?]*)/.exec(redirectUrl) || []; - if (poiID !== '110401125') throw new Error(`Bad POI redirection ${redirectUrl}`); + if (poiID !== 'addr:4.359352;43.84274') + throw new Error(`Bad POI redirection ${redirectUrl}`); }) .end(done); });