Skip to content

Commit 1e1cf24

Browse files
committed
feat(pelias_parser): completely remove "addressit" and references to it
1 parent b2d3b16 commit 1e1cf24

15 files changed

+37
-691
lines changed

middleware/confidenceScore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function computeScores(req, res, next) {
2929
// do nothing if no result data set or if query is not of the original variety
3030
if (check.undefined(req.clean) || check.undefined(res) ||
3131
check.undefined(res.data) || check.undefined(res.meta) ||
32-
res.meta.query_type !== 'search_addressit') {
32+
res.meta.query_type !== 'search_pelias_parser') {
3333
return next();
3434
}
3535

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@
3636
"node": ">=8.0.0"
3737
},
3838
"dependencies": {
39+
"@hapi/joi": "^15.0.0",
3940
"@mapbox/geojson-extent": "^0.3.1",
40-
"addressit": "1.7.0",
4141
"async": "^3.0.1",
4242
"check-types": "^10.0.0",
4343
"elasticsearch": "^16.0.0",
4444
"express": "^4.8.8",
4545
"geojson": "^0.5.0",
4646
"geolib": "^3.0.0",
4747
"iso-639-3": "^1.0.0",
48-
"@hapi/joi": "^15.0.0",
4948
"locale": "^0.1.0",
5049
"lodash": "^4.17.4",
5150
"markdown": "^0.5.0",

query/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function getQuery(vs) {
129129
};
130130
}
131131

132-
// returning undefined is a signal to a later step that the addressit-parsed
132+
// returning undefined is a signal to a later step that a fallback parser
133133
// query should be queried for
134134
return undefined;
135135

query/search_addressit.js query/search_pelias_parser.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ const config = require('pelias-config').generate().api;
88
var placeTypes = require('../helper/placeTypes');
99
var views = { custom_boosts: require('./view/boost_sources_and_layers') };
1010

11-
// region_a is also an admin field. addressit tries to detect
12-
// region_a, in which case we use a match query specifically for it.
13-
// but address it doesn't know about all of them so it helps to search
14-
// against this with the other admin parts as a fallback
11+
// region_a is also an admin field which can be identified by
12+
// the pelias_parser. this functionality was inherited from the
13+
// previous parser we used prior to the creation of pelias_parser.
1514
var adminFields = placeTypes.concat(['region_a']);
1615

1716
//------------------------------
@@ -138,7 +137,7 @@ function generateQuery( clean ){
138137
}
139138

140139
return {
141-
type: 'search_addressit',
140+
type: 'search_pelias_parser',
142141
body: query.render(vs)
143142
};
144143
}

query/text_parser_addressit.js

-99
This file was deleted.

routes/v1.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var controllers = {
3838

3939
var queries = {
4040
cascading_fallback: require('../query/search'),
41-
search_addressit: require('../query/search_addressit'),
41+
search_pelias_parser: require('../query/search_pelias_parser'),
4242
structured_geocoding: require('../query/structured_geocoding'),
4343
reverse: require('../query/reverse'),
4444
autocomplete: require('../query/autocomplete'),
@@ -230,8 +230,8 @@ function addRoutes(app, peliasConfig) {
230230
not(hasResponseData)
231231
);
232232

233-
// call search addressit query if addressit was the parser
234-
const searchAddressitShouldExecute = all(
233+
// call search_pelias_parser query if pelias_parser was the parser
234+
const searchPeliasParserShouldExecute = all(
235235
not(hasRequestErrors),
236236
isPeliasParse
237237
);
@@ -288,11 +288,11 @@ function addRoutes(app, peliasConfig) {
288288
controllers.libpostal(libpostalService, libpostalShouldExecute),
289289
controllers.placeholder(placeholderService, geometricFiltersApply, placeholderGeodisambiguationShouldExecute),
290290
controllers.placeholder(placeholderService, geometricFiltersApply, placeholderIdsLookupShouldExecute),
291-
// try 3 different query types: address search using ids, cascading fallback, addressit
291+
// try 3 different query types: address search using ids, cascading fallback, pelias parser
292292
controllers.search(peliasConfig.api, esclient, queries.address_using_ids, searchWithIdsShouldExecute),
293293
controllers.search(peliasConfig.api, esclient, queries.cascading_fallback, fallbackQueryShouldExecute),
294294
sanitizers.defer_to_pelias_parser(shouldDeferToPeliasParser), //run additional sanitizers needed for pelias parser
295-
controllers.search(peliasConfig.api, esclient, queries.search_addressit, searchAddressitShouldExecute),
295+
controllers.search(peliasConfig.api, esclient, queries.search_pelias_parser, searchPeliasParserShouldExecute),
296296
postProc.trimByGranularity(),
297297
postProc.distances('focus.point.'),
298298
postProc.confidenceScores(peliasConfig.api),

sanitizer/_address_layer_filter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function _setup(tm) {
6060
input = clean.parsed_text.subject;
6161
}
6262

63-
// if 'addressit' or 'libpostal' identified input as a street address
63+
// if 'pelias_parser' or 'libpostal' identified input as a street address
6464
else if (isStreetAddress) {
6565
input = clean.parsed_text.number + ' ' + clean.parsed_text.street;
6666
}

sanitizer/_text_addressit.js

-123
This file was deleted.

test/unit/fixture/search_with_custom_boosts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"type": "search_addressit",
2+
"type": "search_pelias_parser",
33
"body": {
44
"query": {
55
"bool": {

test/unit/middleware/confidenceScore.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports.tests.confidenceScore = function(test, common) {
4747
}],
4848
meta: {
4949
scores: [10],
50-
query_type: 'search_addressit'
50+
query_type: 'search_pelias_parser'
5151
}
5252
};
5353

@@ -89,7 +89,7 @@ module.exports.tests.confidenceScore = function(test, common) {
8989
}],
9090
meta: {
9191
scores: [10],
92-
query_type: 'search_addressit'
92+
query_type: 'search_pelias_parser'
9393
}
9494
};
9595

@@ -125,7 +125,7 @@ module.exports.tests.confidenceScore = function(test, common) {
125125
}],
126126
meta: {
127127
scores: [10],
128-
query_type: 'search_addressit'
128+
query_type: 'search_pelias_parser'
129129
}
130130
};
131131

@@ -134,7 +134,7 @@ module.exports.tests.confidenceScore = function(test, common) {
134134
t.end();
135135
});
136136

137-
test('should only work for search_addressit query_type', function(t) {
137+
test('should only work for search_pelias_parser query_type', function(t) {
138138
var req = {
139139
clean: {
140140
text: '123 Main St, City, NM',
@@ -191,7 +191,7 @@ module.exports.tests.confidenceScore = function(test, common) {
191191
}],
192192
meta: {
193193
scores: [10],
194-
query_type: 'search_addressit'
194+
query_type: 'search_pelias_parser'
195195
}
196196
};
197197

@@ -223,7 +223,7 @@ module.exports.tests.confidenceScore = function(test, common) {
223223
}],
224224
meta: {
225225
scores: [10],
226-
query_type: 'search_addressit'
226+
query_type: 'search_pelias_parser'
227227
}
228228
};
229229

0 commit comments

Comments
 (0)