Added source filtering to tests

This commit is contained in:
Boaz Leskes 2013-07-08 16:35:16 +02:00
parent b6d90d52bd
commit 495667facb
7 changed files with 324 additions and 0 deletions

View File

@ -0,0 +1,45 @@
---
"Source filtering":
- do:
index:
index: test_1
type: test
id: 1
body: { "include": { "field1" : "v1", "field2": "v2" }, "count": 1 }
- do:
indices.refresh:
index: test_1
- do:
explain: { index: test_1, type: test, id: 1, _source: false, body: { query: { match_all: {}} } }
- match: { _index: test_1 }
- match: { _type: test }
- match: { _id: 1 }
- is_false: get._source
- do:
explain: { index: test_1, type: test, id: 1, _source: true, body: { query: { match_all: {}} } }
- match: { get._source.include.field1: v1 }
- do:
explain: { index: test_1, type: test, id: 1, _source: include.field1, body: { query: { match_all: {}} } }
- match: { get._source.include.field1: v1 }
- is_false: get._source.include.field2
- do:
explain: { index: test_1, type: test, id: 1, _source_include: include.field1, body: { query: { match_all: {}} } }
- match: { get._source.include.field1: v1 }
- is_false: get._source.include.field2
- do:
explain: { index: test_1, type: test, id: 1, _source_include: "include.field1,include.field2", body: { query: { match_all: {}} } }
- match: { get._source.include.field1: v1 }
- match: { get._source.include.field2: v2 }
- is_false: get._source.count
- do:
explain: { index: test_1, type: test, id: 1, _source_include: include, _source_exclude: "*.field2", body: { query: { match_all: {}} } }
- match: { get._source.include.field1: v1 }
- is_false: get._source.include.field2
- is_false: get._source.count

View File

@ -0,0 +1,6 @@
Tests missing for:
- everything :)
# preference

View File

@ -20,6 +20,20 @@
- match: { fields.foo: bar }
- is_false: _source
- do:
get:
index: test_1
type: test
id: 1
fields: foo
_source: true
- match: { _index: test_1 }
- match: { _type: test }
- match: { _id: 1 }
- match: { fields.foo: bar }
- match: { _source.foo: bar }
- do:
get:
index: test_1

View File

@ -0,0 +1,42 @@
---
"Source filtering":
- do:
index:
index: test_1
type: test
id: 1
body: { "include": { "field1" : "v1", "field2": "v2" }, "count": 1 }
- do:
get: { index: test_1, type: test, id: 1, _source: false }
- match: { _index: test_1 }
- match: { _type: test }
- match: { _id: 1 }
- is_false: _source
- do:
get: { index: test_1, type: test, id: 1, _source: true }
- match: { _source.include.field1: v1 }
- do:
get: { index: test_1, type: test, id: 1, _source: include.field1 }
- match: { _source.include.field1: v1 }
- is_false: _source.include.field2
- do:
get: { index: test_1, type: test, id: 1, _source_include: include.field1 }
- match: { _source.include.field1: v1 }
- is_false: _source.include.field2
- do:
get: { index: test_1, type: test, id: 1, _source_include: "include.field1,include.field2" }
- match: { _source.include.field1: v1 }
- match: { _source.include.field2: v2 }
- is_false: _source.count
- do:
get: { index: test_1, type: test, id: 1, _source_include: include, _source_exclude: "*.field2" }
- match: { _source.include.field1: v1 }
- is_false: _source.include.field2
- is_false: _source.count

View File

@ -0,0 +1,26 @@
---
"Source filtering":
- do:
index:
index: test_1
type: test
id: 1
body: { "include": { "field1" : "v1", "field2": "v2" }, "count": 1 }
- do:
get_source: { index: test_1, type: test, id: 1, include: include.field1 }
- match: { include.field1: v1 }
- is_false: include.field2
- do:
get_source: { index: test_1, type: test, id: 1, include: "include.field1,include.field2" }
- match: { include.field1: v1 }
- match: { include.field2: v2 }
- is_false: count
- do:
get_source: { index: test_1, type: test, id: 1, include: include, exclude: "*.field2" }
- match: { include.field1: v1 }
- is_false: include.field2
- is_false: count

View File

@ -0,0 +1,99 @@
---
"Source filtering":
- do:
index:
index: test_1
type: test
id: 1
body: { "include": { "field1" : "v1", "field2": "v2" }, "count": 1 }
- do:
index:
index: test_1
type: test
id: 2
body: { "include": { "field1" : "v1", "field2": "v2" }, "count": 1 }
- do:
mget:
body: >
{ docs:
[ { _index: "test_1", _type: "test", _id: "1", _source: false },
{ _index: "test_1", _type: "test", _id: "2", _source: true }
]
}
- match: { docs.0._id: 1 }
- is_false: docs.0._source
- match: { docs.1._id: 2 }
- is_true: docs.1._source
- do:
mget:
body:
docs:
- { _index: "test_1", _type: "test", _id: "1", _source: include.field1 }
- { _index: "test_1", _type: "test", _id: "2", _source: [ include.field1 ] }
- match: { docs.0._source: { include: { field1: v1 }} }
- match: { docs.1._source: { include: { field1: v1 }} }
- do:
mget:
body:
docs:
- { _index: "test_1", _type: "test", _id: "1", _source: { include: include.field1 } }
- { _index: "test_1", _type: "test", _id: "2", _source: { include: [ include.field1 ] } }
- match: { docs.0._source: { include: { field1: v1 }} }
- match: { docs.1._source: { include: { field1: v1 }} }
- do:
mget:
body:
docs:
- { _index: "test_1", _type: "test", _id: "1", _source: { include: [ include ], exclude: [ "*.field2" ] } }
- match: { docs.0._source: { include: { field1: v1 }} }
- do:
mget:
_source: false
index: test_1
body: { ids: [ 1,2 ] }
- is_false: docs.0._source
- is_false: docs.1._source
- do:
mget:
_source: true
index: test_1
body: { ids: [ 1,2 ] }
- is_true: docs.0._source
- is_true: docs.1._source
- do:
mget:
_source: include.field1
index: test_1
body: { ids: [ 1,2 ] }
- match: { docs.0._source: { include: { field1: v1 }} }
- match: { docs.1._source: { include: { field1: v1 }} }
- do:
mget:
_source_include: "include.field1,count"
index: test_1
body: { ids: [ 1,2 ] }
- match: { docs.0._source: { include: { field1: v1 }, count: 1} }
- match: { docs.1._source: { include: { field1: v1 }, count: 1} }
- do:
mget:
_source_include: include
_source_exclude: "*.field2"
index: test_1
body: { ids: [ 1,2 ] }
- match: { docs.0._source: { include: { field1: v1 } } }
- match: { docs.1._source: { include: { field1: v1 } } }

View File

@ -0,0 +1,92 @@
---
"Source filtering":
- do:
index:
index: test_1
type: test
id: 1
body: { "include": { "field1" : "v1", "field2": "v2" }, "count": 1 }
- do:
indices.refresh:
- do:
search:
# stringified for boolean value
body: "{ _source: true, query: { match_all: {} } }"
- length: { hits.hits: 1 }
- match: { hits.hits.0._source.count: 1 }
- do: { search: { body: "{ _source: false, query: { match_all: {} } }" } }
- length: { hits.hits: 1 }
- is_false: hits.hits.0._source
- do: { search: { body: { query: { match_all: {} } } } }
- length: { hits.hits: 1 }
- match: { hits.hits.0._source.count: 1 }
- do: { search: { body: { _source: include.field1, query: { match_all: {} } } } }
- match: { hits.hits.0._source.include.field1: v1 }
- is_false: hits.hits.0._source.include.field2
- do: { search: { _source_include: include.field1, body: { _source: include.field2, query: { match_all: {} } } } }
- match: { hits.hits.0._source.include.field1: v1 }
- is_false: hits.hits.0._source.include.field2
- do: { search: { _source_include: include.field1, body: { query: { match_all: {} } } } }
- match: { hits.hits.0._source.include.field1: v1 }
- is_false: hits.hits.0._source.include.field2
- do: { search: { _source_exclude: count, body: { query: { match_all: {} } } } }
- match: { hits.hits.0._source.include: { field1 : v1 , field2: v2 }}
- is_false: hits.hits.0._source.count
- do:
search:
body:
_source: [ include.field1, include.field2 ]
query: { match_all: {} }
- match: { hits.hits.0._source.include.field1: v1 }
- match: { hits.hits.0._source.include.field2: v2 }
- is_false: hits.hits.0._source.count
- do:
search:
body:
_source:
include: [ include.field1, include.field2 ]
query: { match_all: {} }
- match: { hits.hits.0._source.include.field1: v1 }
- match: { hits.hits.0._source.include.field2: v2 }
- is_false: hits.hits.0._source.count
- do:
search:
body:
_source:
includes: include
excludes: "*.field2"
query: { match_all: {} }
- match: { hits.hits.0._source.include.field1: v1 }
- is_false: hits.hits.0._source.include.field2
- do:
search:
body:
fields: [ include.field2 ]
query: { match_all: {} }
- match: { hits.hits.0.fields: { include.field2 : v2 }}
- is_false: hits.hits.0._source
- do:
search:
body:
fields: [ include.field2, _source ]
query: { match_all: {} }
- match: { hits.hits.0.fields: { include.field2 : v2 }}
- is_true: hits.hits.0._source