Updated test

This commit is contained in:
delvedor
2020-09-07 17:45:26 +02:00
parent 48178df02e
commit 126199a5ea
6 changed files with 547 additions and 657 deletions

View File

@ -20,7 +20,6 @@ test('must only query', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -31,7 +30,6 @@ test('must only query', t => {
{ term: { 11: '12' } }
]
}
}
})
t.end()
@ -60,7 +58,6 @@ test('must and must_not query', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -75,7 +72,6 @@ test('must and must_not query', t => {
{ term: { 15: '16' } }
]
}
}
})
t.end()
@ -106,7 +102,6 @@ test('must and must_not query (mixed and nested)', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -121,7 +116,6 @@ test('must and must_not query (mixed and nested)', t => {
{ match: { 13: '14' } }
]
}
}
})
t.end()
@ -140,7 +134,6 @@ test('must and should query', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -151,7 +144,6 @@ test('must and should query', t => {
{ term: { 7: '8' } }
]
}
}
})
t.end()
@ -178,7 +170,6 @@ test('must and should query (nested) / 1', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -197,7 +188,6 @@ test('must and should query (nested) / 1', t => {
}
]
}
}
})
t.end()
@ -222,7 +212,6 @@ test('must and should query (nested) / 2', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -241,7 +230,6 @@ test('must and should query (nested) / 2', t => {
}
]
}
}
})
t.end()
@ -266,7 +254,6 @@ test('must and filter query / 1', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -279,7 +266,6 @@ test('must and filter query / 1', t => {
{ term: { 11: '12' } }
]
}
}
})
t.end()
@ -302,7 +288,6 @@ test('must and filter query / 2', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -315,7 +300,6 @@ test('must and filter query / 2', t => {
{ term: { 11: '12' } }
]
}
}
})
t.end()
@ -338,7 +322,6 @@ test('all but should query / 1', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -353,7 +336,6 @@ test('all but should query / 1', t => {
{ term: { 11: '12' } }
]
}
}
})
t.end()
@ -376,7 +358,6 @@ test('all but should query / 2', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -391,7 +372,6 @@ test('all but should query / 2', t => {
{ term: { 11: '12' } }
]
}
}
})
t.end()
@ -418,7 +398,6 @@ test('all but should query / 3', t => {
)
t.deepEqual(query, {
query: {
bool: {
must_not: [
{ match: { 5: '6' } },
@ -431,7 +410,6 @@ test('all but should query / 3', t => {
{ term: { 11: '12' } }
]
}
}
})
t.end()
@ -466,7 +444,6 @@ test('all but should query / 4', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 17: '18' } },
@ -485,7 +462,6 @@ test('all but should query / 4', t => {
{ term: { 11: '12' } }
]
}
}
})
t.end()
@ -508,7 +484,6 @@ test('filter with should', t => {
)
t.deepEqual(query, {
query: {
bool: {
filter: [
{
@ -525,7 +500,6 @@ test('filter with should', t => {
}
]
}
}
})
t.end()
@ -544,14 +518,12 @@ test('nested with only should', t => {
)
t.deepEqual(query, {
query: {
bool: {
should: [
{ match: { 1: '2' } },
{ term: { 3: '4' } }
]
}
}
})
t.end()
@ -571,7 +543,6 @@ test('nested with only should and minimum_should_match / 1', t => {
)
t.deepEqual(query, {
query: {
bool: {
should: [{
bool: {
@ -583,7 +554,6 @@ test('nested with only should and minimum_should_match / 1', t => {
}
}]
}
}
})
t.end()
@ -602,7 +572,6 @@ test('nested with only should and minimum_should_match / 2', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [{
bool: {
@ -617,7 +586,6 @@ test('nested with only should and minimum_should_match / 2', t => {
match: { 5: '6' }
}]
}
}
})
t.end()
@ -640,7 +608,6 @@ test('nested with should and other clause', t => {
)
t.deepEqual(query, {
query: {
bool: {
should: [{
bool: {
@ -655,7 +622,6 @@ test('nested with should and other clause', t => {
}
}]
}
}
})
t.end()
@ -672,14 +638,12 @@ test('nested with only should', t => {
)
t.deepEqual(query, {
query: {
bool: {
should: [
{ match: { 1: '2' } },
{ term: { 3: '4' } }
]
}
}
})
t.end()
@ -697,7 +661,6 @@ test('nested with only should and minimum_should_match', t => {
)
t.deepEqual(query, {
query: {
bool: {
should: [
{ match: { 1: '2' } },
@ -705,7 +668,6 @@ test('nested with only should and minimum_should_match', t => {
],
minimum_should_match: 1
}
}
})
t.end()
@ -729,7 +691,6 @@ test('Should not merge up named queries / 1', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -747,7 +708,6 @@ test('Should not merge up named queries / 1', t => {
}
]
}
}
})
t.end()
@ -771,7 +731,6 @@ test('Should not merge up named queries / 2', t => {
)
t.deepEqual(query, {
query: {
bool: {
must: [
{ match: { 1: '2' } },
@ -789,7 +748,6 @@ test('Should not merge up named queries / 2', t => {
}
]
}
}
})
t.end()

View File

@ -183,14 +183,12 @@ test('AND', t => {
const query2 = Q.term('baz', 'faz')
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -201,12 +199,10 @@ test('AND', t => {
const query2 = Q.term('baz', 'faz')
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [{ term: { baz: 'faz' } }],
should: [{ match: { foo: 'bar' } }]
}
}
})
t.end()
@ -217,14 +213,12 @@ test('AND', t => {
const query2 = Q.term('baz', 'faz')
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -235,12 +229,10 @@ test('AND', t => {
function noShouldClauses (t, query1, query2) {
t.test('No should clauses', t => {
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [{ match: { foo: 'bar' } }],
filter: [{ term: { baz: 'faz' } }]
}
}
})
t.end()
@ -250,7 +242,6 @@ test('AND', t => {
function noShouldClausesWithName (t, query1, query2) {
t.test('No should clauses with name', t => {
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [{
bool: {
@ -260,7 +251,6 @@ test('AND', t => {
}],
filter: [{ term: { baz: 'faz' } }]
}
}
})
t.deepEqual(Q.and(query1, query2), Q.and(query2, query1))
@ -272,7 +262,6 @@ test('AND', t => {
function shouldClauses (t, query1, query2) {
t.test('Should clauses', t => {
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
@ -285,7 +274,6 @@ test('AND', t => {
}
]
}
}
})
t.end()
@ -295,14 +283,12 @@ test('AND', t => {
function sameClauseNoShould (t, query1, query2) {
t.test('same clauses without should', t => {
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -312,7 +298,6 @@ test('AND', t => {
function sameClauseYesShould (t, query1, query2) {
t.test('same clauses with should', t => {
t.deepEqual(Q.and(query1, query2), {
query: {
bool: {
must: [
{
@ -327,7 +312,6 @@ test('AND', t => {
{ match: { foo: 'bar' } }
]
}
}
})
t.end()
@ -337,7 +321,6 @@ test('AND', t => {
function moreNoShould (t, query1, query2, query3) {
t.test('More than two clauses without should', t => {
t.deepEqual(Q.and(query1, query2, query3), {
query: {
bool: {
must: [{ match: { foo: 'bar' } }],
filter: [
@ -345,7 +328,6 @@ test('AND', t => {
{ term: { winter: 'is coming' } }
]
}
}
})
t.end()
@ -355,7 +337,6 @@ test('AND', t => {
function moreYesShould (t, query1, query2, query3) {
t.test('More than two clauses with should', t => {
t.deepEqual(Q.and(query1, query2, query3), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
@ -369,7 +350,6 @@ test('AND', t => {
],
filter: [{ term: { baz: 'faz' } }]
}
}
})
t.end()

View File

@ -11,7 +11,6 @@ test('NOT', t => {
)
t.deepEqual(Q.not(query), {
query: {
bool: {
must_not: [{
bool: {
@ -20,7 +19,6 @@ test('NOT', t => {
}
}]
}
}
})
t.end()
@ -32,12 +30,10 @@ test('NOT', t => {
Q.mustNot(Q.term('baz', 'faz'))
)
t.deepEqual(Q.not(query), {
query: {
bool: {
must_not: [{ match: { foo: 'bar' } }],
must: [{ term: { baz: 'faz' } }]
}
}
})
t.end()
@ -49,13 +45,11 @@ test('NOT', t => {
)
t.deepEqual(Q.not(query), {
query: {
bool: {
must_not: [{
match: { foo: 'bar' }
}]
}
}
})
t.end()
@ -67,13 +61,11 @@ test('NOT', t => {
)
t.deepEqual(Q.not(query), {
query: {
bool: {
must: [{
match: { foo: 'bar' }
}]
}
}
})
t.end()
@ -83,13 +75,11 @@ test('NOT', t => {
const query = Q.must(Q.match('foo', 'bar'))
t.deepEqual(Q.not(query), {
query: {
bool: {
must_not: [{
match: { foo: 'bar' }
}]
}
}
})
t.end()
@ -99,7 +89,6 @@ test('NOT', t => {
const query = Q.should(Q.match('foo', 'bar'))
t.deepEqual(Q.not(query), {
query: {
bool: {
must_not: [{
bool: {
@ -109,7 +98,6 @@ test('NOT', t => {
}
}]
}
}
})
t.end()
@ -119,7 +107,6 @@ test('NOT', t => {
const query = Q.filter(Q.match('foo', 'bar'))
t.deepEqual(Q.not(query), {
query: {
bool: {
must_not: [{
bool: {
@ -129,7 +116,6 @@ test('NOT', t => {
}
}]
}
}
})
t.end()
@ -139,13 +125,11 @@ test('NOT', t => {
const query = Q.mustNot(Q.match('foo', 'bar'))
t.deepEqual(Q.not(query), {
query: {
bool: {
must: [{
match: { foo: 'bar' }
}]
}
}
})
t.end()
@ -155,13 +139,11 @@ test('NOT', t => {
const query = Q.match('foo', 'bar')
t.deepEqual(Q.not(query), {
query: {
bool: {
must_not: [{
match: { foo: 'bar' }
}]
}
}
})
t.end()

View File

@ -177,14 +177,12 @@ test('OR', t => {
const query2 = Q.term('baz', 'faz')
t.deepEqual(Q.or(query1, query2), {
query: {
bool: {
should: [
{ bool: { must: [{ match: { foo: 'bar' } }] } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -195,14 +193,12 @@ test('OR', t => {
const query2 = Q.term('baz', 'faz')
t.deepEqual(Q.or(query1, query2), {
query: {
bool: {
should: [
{ match: { foo: 'bar' } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -213,14 +209,12 @@ test('OR', t => {
const query2 = Q.term('baz', 'faz')
t.deepEqual(Q.or(query1, query2), {
query: {
bool: {
should: [
{ match: { foo: 'bar' } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -231,14 +225,12 @@ test('OR', t => {
function noShouldClauses (t, query1, query2) {
t.test('No should clauses', t => {
t.deepEqual(Q.or(query1, query2), {
query: {
bool: {
should: [
{ bool: { must: [{ match: { foo: 'bar' } }] } },
{ bool: { filter: [{ term: { baz: 'faz' } }] } }
]
}
}
})
t.end()
@ -248,14 +240,12 @@ test('OR', t => {
function shouldClauses (t, query1, query2) {
t.test('Should clauses', t => {
t.deepEqual(Q.or(query1, query2), {
query: {
bool: {
should: [
{ bool: { must: [{ match: { foo: 'bar' } }] } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -265,14 +255,12 @@ test('OR', t => {
function sameClauseNoShould (t, query1, query2) {
t.test('same clauses without should', t => {
t.deepEqual(Q.or(query1, query2), {
query: {
bool: {
should: [
{ bool: { must: [{ match: { foo: 'bar' } }] } },
{ bool: { must: [{ term: { baz: 'faz' } }] } }
]
}
}
})
t.end()
@ -282,14 +270,12 @@ test('OR', t => {
function sameClauseYesShould (t, query1, query2) {
t.test('same clauses with should', t => {
t.deepEqual(Q.or(query1, query2), {
query: {
bool: {
should: [
{ match: { foo: 'bar' } },
{ term: { baz: 'faz' } }
]
}
}
})
t.end()
@ -299,7 +285,6 @@ test('OR', t => {
function moreNoShould (t, query1, query2, query3) {
t.test('More than two clauses without should', t => {
t.deepEqual(Q.or(query1, query2, query3), {
query: {
bool: {
should: [
{ bool: { must: [{ match: { foo: 'bar' } }] } },
@ -307,7 +292,6 @@ test('OR', t => {
{ bool: { filter: [{ term: { winter: 'is coming' } }] } }
]
}
}
})
t.end()
@ -317,7 +301,6 @@ test('OR', t => {
function moreYesShould (t, query1, query2, query3) {
t.test('More than two clauses with should', t => {
t.deepEqual(Q.or(query1, query2, query3), {
query: {
bool: {
should: [
{ bool: { must: [{ match: { foo: 'bar' } }] } },
@ -325,7 +308,6 @@ test('OR', t => {
{ term: { winter: 'is coming' } }
]
}
}
})
t.end()

View File

@ -1,85 +1,85 @@
'use strict'
import { test } from 'tap'
/* eslint-disable no-unused-vars */
import * as types from '../../dsl/lib/types'
/* eslint-enable no-unused-vars */
import { F, Q } from '../../dsl'
// import { test } from 'tap'
// /* eslint-disable no-unused-vars */
// import * as types from '../../dsl/lib/types'
// /* eslint-enable no-unused-vars */
// import { F, Q } from '../../dsl'
test('match', t => {
t.deepEqual(F()
.match('foo', 'bar')
.match('foo', 'baz')
.build(),
Q(
Q.match('foo', 'bar'),
Q.match('foo', 'baz')
)
)
// test('match', t => {
// t.deepEqual(F()
// .match('foo', 'bar')
// .match('foo', 'baz')
// .build(),
// Q(
// Q.match('foo', 'bar'),
// Q.match('foo', 'baz')
// )
// )
t.deepEqual(F()
.match('foo', ['bar', 'baz'])
.build(),
Q(
Q.match('foo', ['bar', 'baz'])
)
)
// t.deepEqual(F()
// .match('foo', ['bar', 'baz'])
// .build(),
// Q(
// Q.match('foo', ['bar', 'baz'])
// )
// )
t.end()
})
// t.end()
// })
test('matchPhrase', t => {
t.deepEqual(F()
.matchPhrase('foo', 'bar')
.build(),
Q(Q.matchPhrase('foo', 'bar'))
)
// test('matchPhrase', t => {
// t.deepEqual(F()
// .matchPhrase('foo', 'bar')
// .build(),
// Q(Q.matchPhrase('foo', 'bar'))
// )
t.end()
})
// t.end()
// })
test('matchPhrasePrefix', t => {
t.deepEqual(F()
.matchPhrasePrefix('foo', 'bar')
.build(),
Q(Q.matchPhrasePrefix('foo', 'bar'))
)
// test('matchPhrasePrefix', t => {
// t.deepEqual(F()
// .matchPhrasePrefix('foo', 'bar')
// .build(),
// Q(Q.matchPhrasePrefix('foo', 'bar'))
// )
t.end()
})
// t.end()
// })
test('multiMatch', t => {
t.deepEqual(F()
.multiMatch(['foo1', 'foo2'], 'bar')
.build(),
Q(Q.multiMatch(['foo1', 'foo2'], 'bar'))
)
// test('multiMatch', t => {
// t.deepEqual(F()
// .multiMatch(['foo1', 'foo2'], 'bar')
// .build(),
// Q(Q.multiMatch(['foo1', 'foo2'], 'bar'))
// )
t.end()
})
// t.end()
// })
test('matchAll', t => {
t.deepEqual(F()
.matchAll()
.build(),
Q(Q.matchAll())
)
// test('matchAll', t => {
// t.deepEqual(F()
// .matchAll()
// .build(),
// Q(Q.matchAll())
// )
t.deepEqual(F()
.matchAll({ boost: 1 })
.build(),
Q(Q.matchAll({ boost: 1 }))
)
// t.deepEqual(F()
// .matchAll({ boost: 1 })
// .build(),
// Q(Q.matchAll({ boost: 1 }))
// )
t.end()
})
// t.end()
// })
test('matchNone', t => {
t.deepEqual(F()
.matchNone()
.build(),
Q(Q.matchNone())
)
// test('matchNone', t => {
// t.deepEqual(F()
// .matchNone()
// .build(),
// Q(Q.matchNone())
// )
t.end()
})
// t.end()
// })

View File

@ -9,13 +9,13 @@ import { Q } from '../../dsl'
test('Q is a function that creates the final query object', t => {
t.type(Q, 'function')
t.deepEqual(Q({ a: 1 }, { b: 2 }, { c: 3 }), {
t.deepEqual(Q(c('a'), c('b'), c('c')), {
query: {
bool: {
must: [
{ a: 1 },
{ b: 2 },
{ c: 3 }
c('a'),
c('b'),
c('c')
]
}
}
@ -66,9 +66,9 @@ test('Q is a function that creates the final query object', t => {
[randomTopLevelKey]: 42
})
t.deepEqual(Q({ query: { function_score: { foo: 'bar' } } }, { [randomTopLevelKey]: 42 }), {
t.deepEqual(Q({ query: { function_score: { max_boost: 42 } } }, { [randomTopLevelKey]: 42 }), {
query: {
function_score: { foo: 'bar' }
function_score: { max_boost: 42 }
},
[randomTopLevelKey]: 42
})
@ -88,9 +88,9 @@ test('Compile a query (safe)', t => {
t.type(Q.compile, 'function')
const query = Q(
{ a: Q.param('a') },
{ b: Q.param('b') },
{ c: Q.param('c') }
Q.match('a', Q.param('a')),
Q.match('b', Q.param('b')),
Q.match('c', Q.param('c'))
)
interface Input {
@ -104,9 +104,9 @@ test('Compile a query (safe)', t => {
query: {
bool: {
must: [
{ a: 1 },
{ b: 2 },
{ c: 3 }
{ match: { a: 1 } },
{ match: { b: 2 } },
{ match: { c: 3 } }
]
}
}
@ -126,9 +126,9 @@ test('Compile a query (unsafe)', t => {
t.type(Q.compile, 'function')
const query = Q(
{ a: Q.param('a') },
{ b: Q.param('b') },
{ c: Q.param('c') }
Q.match('a', Q.param('a')),
Q.match('b', Q.param('b')),
Q.match('c', Q.param('c'))
)
interface Input {
@ -142,9 +142,9 @@ test('Compile a query (unsafe)', t => {
query: {
bool: {
must: [
{ a: 1 },
{ b: 2 },
{ c: 3 }
{ match: { a: 1 } },
{ match: { b: 2 } },
{ match: { c: 3 } }
]
}
}
@ -170,11 +170,11 @@ test('match returns a match query', t => {
})
t.test('complex query', t => {
t.deepEqual(Q.match('foo', 'bar', { operator: 'and' }), {
t.deepEqual(Q.match('foo', 'bar', { analyzer: 'and' }), {
match: {
foo: {
query: 'bar',
operator: 'and'
analyzer: 'and'
}
}
})
@ -237,11 +237,11 @@ test('matchPhrasePrefix returns a match_phrase_prefix query', t => {
test('multiMatch returns a multi_match query', t => {
t.type(Q.multiMatch, 'function')
t.deepEqual(Q.multiMatch(['foo', 'baz'], 'bar', { type: 'best_fields' }), {
t.deepEqual(Q.multiMatch(['foo', 'baz'], 'bar', { analyzer: 'best_fields' }), {
multi_match: {
query: 'bar',
fields: ['foo', 'baz'],
type: 'best_fields'
analyzer: 'best_fields'
}
})
@ -251,8 +251,8 @@ test('multiMatch returns a multi_match query', t => {
test('matchAll returns a match_all query', t => {
t.type(Q.matchAll, 'function')
t.deepEqual(Q.matchAll({ boost: 1.2 }), {
match_all: { boost: 1.2 }
t.deepEqual(Q.matchAll({ norm_field: 'foobar' }), {
match_all: { norm_field: 'foobar' }
})
t.end()
@ -299,10 +299,10 @@ test('queryString returns a query_string query', t => {
test('simpleQueryString returns a simple_query_string query', t => {
t.type(Q.simpleQueryString, 'function')
t.deepEqual(Q.simpleQueryString('foo', { default_field: 'content' }), {
t.deepEqual(Q.simpleQueryString('foo', { analyzer: 'content' }), {
simple_query_string: {
query: 'foo',
default_field: 'content'
analyzer: 'content'
}
})
@ -756,27 +756,23 @@ test('bool returns a bool query block', t => {
t.type(Q.bool, 'function')
t.deepEqual(Q.bool(Q.must(c('foo')), Q.should(c('bar')), Q.filter(c('baz'))), {
query: {
bool: {
must: [c('foo')],
should: [c('bar')],
filter: [c('baz')]
}
}
})
t.deepEqual(Q.bool(), { query: { bool: {} } })
t.deepEqual(Q.bool(undefined), { query: { bool: {} } })
t.deepEqual(Q.bool(), { bool: {} })
t.deepEqual(Q.bool(undefined), { bool: {} })
t.deepEqual(Q.bool(Q.must(c('foo')), Q.should(c('bar')), Q.mustNot(c('foz')), Q.filter(c('baz'), c('faz'))), {
query: {
bool: {
must: [c('foo')],
must_not: [c('foz')],
should: [c('bar')],
filter: [c('baz'), c('faz')]
}
}
})
t.deepEqual(Q.bool(
@ -788,7 +784,6 @@ test('bool returns a bool query block', t => {
Q.should(c('bar')),
Q.filter(c('baz'))
), {
query: {
bool: {
must: [
c('foo'),
@ -797,7 +792,6 @@ test('bool returns a bool query block', t => {
should: [c('bar')],
filter: [c('baz')]
}
}
})
t.deepEqual(Q.bool(
@ -806,7 +800,6 @@ test('bool returns a bool query block', t => {
Q.match('baz', 'faz'),
Q.minShouldMatch(1)
), {
query: {
bool: {
must: [
{ term: { hello: 'world' } }
@ -817,7 +810,6 @@ test('bool returns a bool query block', t => {
],
minimum_should_match: 1
}
}
})
t.deepEqual(Q.bool(
@ -826,7 +818,6 @@ test('bool returns a bool query block', t => {
Q.match('baz', 'faz'),
Q.minShouldMatch(2)
), {
query: {
bool: {
must: [
{ term: { hello: 'world' } },
@ -834,7 +825,6 @@ test('bool returns a bool query block', t => {
{ match: { baz: 'faz' } }
]
}
}
})
t.deepEqual(Q.bool(
@ -842,14 +832,12 @@ test('bool returns a bool query block', t => {
Q.match('baz', 'faz'),
Q.minShouldMatch(2)
), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
{ match: { baz: 'faz' } }
]
}
}
})
t.end()
@ -892,10 +880,10 @@ test('disMax returns a dis_max query block', t => {
t.type(Q.disMax, 'function')
t.test('simple query', t => {
t.deepEqual(Q.disMax([{ a: 1 }, { b: 2 }, { c: 3 }]), {
t.deepEqual(Q.disMax([c('a'), c('b'), c('c')]), {
query: {
dis_max: {
queries: [{ a: 1 }, { b: 2 }, { c: 3 }]
queries: [c('a'), c('b'), c('c')]
}
}
})
@ -903,12 +891,12 @@ test('disMax returns a dis_max query block', t => {
})
t.test('complex query', t => {
t.deepEqual(Q.disMax([{ a: 1 }, { b: 2 }, { c: 3 }], { tie_breaker: 1.0, boost: 1.0 }), {
t.deepEqual(Q.disMax([c('a'), c('b'), c('c')], { tie_breaker: 1.0, boost: 1.0 }), {
query: {
dis_max: {
tie_breaker: 1.0,
boost: 1.0,
queries: [{ a: 1 }, { b: 2 }, { c: 3 }]
queries: [c('a'), c('b'), c('c')]
}
}
})
@ -987,5 +975,5 @@ test('name', t => {
// build a condition bloc
function c (key: string): types.Condition {
return { [key]: key }
return { match: { [key]: key } }
}