Browse Source

added support for `_matched_queries` in ES hits

this will make it easier to sort thru results from FallbackQuery by knowing which query was called
pull/666/head
Stephen Hess 8 years ago
parent
commit
8d532adb3f
  1. 1
      service/search.js
  2. 2
      test/unit/mock/backend.js
  3. 8
      test/unit/service/search.js

1
service/search.js

@ -35,6 +35,7 @@ function service( backend, cmd, cb ){
hit._source._id = hit._id;
hit._source._type = hit._type;
hit._source._score = hit._score;
hit._source._matched_queries = hit._matched_queries;
return hit._source;
});

2
test/unit/mock/backend.js

@ -11,6 +11,7 @@ responses['client/search/ok/1'] = function( cmd, cb ){
_id: 'myid1',
_type: 'mytype1',
_score: 10,
_matched_queries: ['query 1', 'query 2'],
_source: {
value: 1,
center_point: { lat: 100.1, lon: -50.5 },
@ -21,6 +22,7 @@ responses['client/search/ok/1'] = function( cmd, cb ){
_id: 'myid2',
_type: 'mytype2',
_score: 20,
_matched_queries: ['query 3'],
_source: {
value: 2,
center_point: { lat: 100.2, lon: -51.5 },

8
test/unit/service/search.js

@ -13,21 +13,23 @@ module.exports.tests.interface = function(test, common) {
});
};
// functionally test service
// functionally test service
module.exports.tests.functional_success = function(test, common) {
var expected = [
{
_id: 'myid1', _type: 'mytype1',
_score: 10,
_matched_queries: ['query 1', 'query 2'],
value: 1,
center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' },
parent: { country: ['country1'], region: ['state1'], county: ['city1'] }
},
},
{
_id: 'myid2', _type: 'mytype2',
_score: 20,
_matched_queries: ['query 3'],
value: 2,
center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' },
@ -88,4 +90,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};

Loading…
Cancel
Save