Browse Source

enable shingle matching

pull/153/head
Peter Johnson 10 years ago
parent
commit
60a02315ae
  1. 13
      query/search.js
  2. 24
      test/unit/query/search.js

13
query/search.js

@ -30,9 +30,20 @@ function generate( params ){
} }
}; };
// should query contitions
query.query.filtered.query.bool.should = [];
// add shingles should query
// note: this is required for partial phrase matching
query.query.filtered.query.bool.should.push({
'multi_match': {
'query': params.input,
'fields': [ 'shingle.*' ]
}
});
if (params.input_admin) { if (params.input_admin) {
var admin_fields = ['admin0', 'admin1', 'admin1_abbr', 'admin2', 'alpha3']; var admin_fields = ['admin0', 'admin1', 'admin1_abbr', 'admin2', 'alpha3'];
query.query.filtered.query.bool.should = [];
admin_fields.forEach(function(admin_field) { admin_fields.forEach(function(admin_field) {
var match = {}; var match = {};

24
test/unit/query/search.js

@ -83,6 +83,14 @@ var expected = {
'fields': [ 'name.*' ] 'fields': [ 'name.*' ]
} }
} }
],
'should': [
{
'multi_match': {
'query': 'test',
'fields': [ 'shingle.*' ]
}
}
] ]
} }
}, },
@ -163,6 +171,14 @@ module.exports.tests.query = function(test, common) {
'fields': [ 'name.*' ] 'fields': [ 'name.*' ]
} }
} }
],
'should': [
{
'multi_match': {
'query': 'test',
'fields': [ 'shingle.*' ]
}
}
] ]
} }
}, },
@ -201,6 +217,14 @@ module.exports.tests.query = function(test, common) {
'fields': [ 'name.*' ] 'fields': [ 'name.*' ]
} }
} }
],
'should': [
{
'multi_match': {
'query': 'test',
'fields': [ 'shingle.*' ]
}
}
] ]
} }
}, },

Loading…
Cancel
Save