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 9 years ago
parent
commit
8d532adb3f
  1. 1
      service/search.js
  2. 2
      test/unit/mock/backend.js
  3. 2
      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._id = hit._id;
hit._source._type = hit._type; hit._source._type = hit._type;
hit._source._score = hit._score; hit._source._score = hit._score;
hit._source._matched_queries = hit._matched_queries;
return hit._source; return hit._source;
}); });

2
test/unit/mock/backend.js

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

2
test/unit/service/search.js

@ -20,6 +20,7 @@ module.exports.tests.functional_success = function(test, common) {
{ {
_id: 'myid1', _type: 'mytype1', _id: 'myid1', _type: 'mytype1',
_score: 10, _score: 10,
_matched_queries: ['query 1', 'query 2'],
value: 1, value: 1,
center_point: { lat: 100.1, lon: -50.5 }, center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' }, name: { default: 'test name1' },
@ -28,6 +29,7 @@ module.exports.tests.functional_success = function(test, common) {
{ {
_id: 'myid2', _type: 'mytype2', _id: 'myid2', _type: 'mytype2',
_score: 20, _score: 20,
_matched_queries: ['query 3'],
value: 2, value: 2,
center_point: { lat: 100.2, lon: -51.5 }, center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' }, name: { default: 'test name2' },

Loading…
Cancel
Save