Browse Source

enable shingle matching

pull/153/head
Peter Johnson 10 years ago
parent
commit
60a02315ae
  1. 13
      query/search.js
  2. 30
      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) {
var admin_fields = ['admin0', 'admin1', 'admin1_abbr', 'admin2', 'alpha3'];
query.query.filtered.query.bool.should = [];
admin_fields.forEach(function(admin_field) {
var match = {};

30
test/unit/query/search.js

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

Loading…
Cancel
Save