From 89c08068dd8ec923211e7404fc83e07b4b6fed64 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 17 May 2016 13:37:22 -0700 Subject: [PATCH] use filter instead of must in query faster, and the score does not matter here --- src/worker.js | 4 ++-- test/src/worker.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/worker.js b/src/worker.js index 3de32b1..25c6120 100644 --- a/src/worker.js +++ b/src/worker.js @@ -235,11 +235,11 @@ export default class Job extends events.EventEmitter { constant_score: { filter: { bool: { - must: { term: { jobtype: this.jobtype } }, + filter: { term: { jobtype: this.jobtype } }, should: [ { term: { status: 'pending'} }, { bool: - { must: [ + { filter: [ { term: { status: 'processing' } }, { range: { process_expiration: { lte: nowTime } } } ] } diff --git a/test/src/worker.js b/test/src/worker.js index 86be3c3..2dde223 100644 --- a/test/src/worker.js +++ b/test/src/worker.js @@ -231,8 +231,7 @@ describe('Worker class', function () { it('should search by job type', function () { const { body } = getSearchParams(jobtype); const conditions = get(body, conditionPath); - expect(conditions).to.have.property('must'); - expect(conditions.must).to.eql({ term: { jobtype: jobtype } }); + expect(conditions.filter).to.eql({ term: { jobtype: jobtype } }); }); it('should search for pending or expired jobs', function () { @@ -243,7 +242,7 @@ describe('Worker class', function () { // this works because we are stopping the clock, so all times match const nowTime = moment().toISOString(); const pending = { term: { status: 'pending'} }; - const expired = { bool: { must: [ + const expired = { bool: { filter: [ { term: { status: 'processing' } }, { range: { process_expiration: { lte: nowTime } } } ] } };