Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Fulltext query: use specialized search enpoint #1085

Merged
merged 1 commit into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/middlewares/fullText_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
118 changes: 118 additions & 0 deletions tests/__data__/search_type.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
}
]
}
18 changes: 9 additions & 9 deletions tests/integration/server_start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/tests/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down