Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add peliasDefaultSimilarity #430

Merged
merged 1 commit into from
Jan 13, 2020
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
24 changes: 16 additions & 8 deletions mappings/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,38 @@ var schema = {
name: {
type: 'text',
analyzer: 'keyword',
search_analyzer: 'keyword'
search_analyzer: 'keyword',
similarity: 'peliasDefaultSimilarity'
},
unit: {
type: 'text',
analyzer: 'peliasUnit',
search_analyzer: 'peliasUnit'
search_analyzer: 'peliasUnit',
similarity: 'peliasDefaultSimilarity'
},
number: {
type: 'text',
analyzer: 'peliasHousenumber',
search_analyzer: 'peliasHousenumber'
search_analyzer: 'peliasHousenumber',
similarity: 'peliasDefaultSimilarity'
},
street: {
type: 'text',
analyzer: 'peliasStreet',
search_analyzer: 'peliasStreet'
search_analyzer: 'peliasStreet',
similarity: 'peliasDefaultSimilarity'
},
cross_street: {
type: 'text',
analyzer: 'peliasStreet',
search_analyzer: 'peliasStreet'
search_analyzer: 'peliasStreet',
similarity: 'peliasDefaultSimilarity'
},
zip: {
type: 'text',
analyzer: 'peliasZip',
search_analyzer: 'peliasZip'
search_analyzer: 'peliasZip',
similarity: 'peliasDefaultSimilarity'
},
}
},
Expand Down Expand Up @@ -159,7 +165,8 @@ var schema = {
mapping: {
type: 'text',
analyzer: 'peliasIndexOneEdgeGram',
search_analyzer: 'peliasQuery'
search_analyzer: 'peliasQuery',
similarity: 'peliasDefaultSimilarity'
}
},
},{
Expand All @@ -169,7 +176,8 @@ var schema = {
mapping: {
type: 'text',
analyzer: 'peliasPhrase',
search_analyzer: 'peliasQuery'
search_analyzer: 'peliasQuery',
similarity: 'peliasDefaultSimilarity'
}
}
},{
Expand Down
2 changes: 2 additions & 0 deletions mappings/partial/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"type": "text",
"analyzer": "peliasAdmin",
"search_analyzer": "peliasAdmin",
"similarity": "peliasDefaultSimilarity",
"fields": {
"ngram": {
"type": "text",
"analyzer": "peliasIndexOneEdgeGram",
"search_analyzer": "peliasAdmin",
"similarity": "peliasDefaultSimilarity",
"doc_values": false
}
}
Expand Down
4 changes: 3 additions & 1 deletion mappings/partial/postalcode.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"type": "text",
"analyzer": "peliasZip",
"search_analyzer": "peliasZip",
"similarity": "peliasDefaultSimilarity",
"fields": {
"ngram": {
"type": "text",
"analyzer": "peliasIndexOneEdgeGram",
"search_analyzer": "peliasZip"
"search_analyzer": "peliasZip",
"similarity": "peliasDefaultSimilarity"
}
}
}
21 changes: 13 additions & 8 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ function generate(){

// Default settings
var settings = {
"index": {
"similarity": {
"peliasDefaultSimilarity": {
"type": "BM25",
"k1": 1.2,
"b": 0.75
}
}
},
"analysis": {
"tokenizer": {
"peliasNameTokenizer": {
Expand Down Expand Up @@ -211,19 +220,15 @@ function generate(){

// dynamically create filters for all synonym files in the ./synonyms directory.
// each filter is given the same name as the file, minus the extension.
for( var key in synonyms ){
_.each(synonyms, (synonym, key) => {
settings.analysis.filter[key] = {
"type": "synonym",
"synonyms": !!synonyms[key].length ? synonyms[key] : ['']
"synonyms": !_.isEmpty(synonym) ? synonym : ['']
};
}
})

// Merge settings from pelias/config
if( 'object' === typeof config &&
'object' === typeof config.elasticsearch &&
'object' === typeof config.elasticsearch.settings ){
return _.merge({}, settings, config.elasticsearch.settings);
}
settings = _.merge({}, settings, _.get(config, 'elasticsearch.settings', {}));

return settings;
}
Expand Down
6 changes: 4 additions & 2 deletions test/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ module.exports.tests.dynamic_templates = function(test, common) {
t.deepEqual(template.mapping, {
type: 'text',
analyzer: 'peliasIndexOneEdgeGram',
search_analyzer: 'peliasQuery'
search_analyzer: 'peliasQuery',
similarity: 'peliasDefaultSimilarity'
});
t.end();
});
Expand All @@ -55,7 +56,8 @@ module.exports.tests.dynamic_templates = function(test, common) {
t.deepEqual(template.mapping, {
type: 'text',
analyzer: 'peliasPhrase',
search_analyzer: 'peliasQuery'
search_analyzer: 'peliasQuery',
similarity: 'peliasDefaultSimilarity'
});
t.end();
});
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading