Browse Source

switching to bool with a 'must' match (AND) and a few 'should's (OR)

pull/68/head
Harish Krishna 10 years ago
parent
commit
2127ebe258
  1. 24
      query/search.js

24
query/search.js

@ -22,12 +22,28 @@ function generate( params ){
// add search condition to distance query
query.query.filtered.query = {
query_string : {
query: params.input,
fields: ['name.default'],
default_operator: 'OR'
'bool': {
'must': [{
'match': {
'name.default': params.input
}
}
]
}
};
if (params.input_admin) {
var admin_fields = ['admin0', 'admin1', 'alpha3'];
query.query.filtered.query.bool.should = [];
admin_fields.forEach(function(admin_field) {
var match = {};
match[admin_field] = params.input_admin;
query.query.filtered.query.bool.should.push({
'match': match
});
});
}
query.sort = query.sort.concat(sort);

Loading…
Cancel
Save