summaryrefslogtreecommitdiff
path: root/rest-api-spec/test/get
diff options
context:
space:
mode:
Diffstat (limited to 'rest-api-spec/test/get')
-rw-r--r--rest-api-spec/test/get/10_basic.yaml31
-rw-r--r--rest-api-spec/test/get/15_default_values.yaml21
-rw-r--r--rest-api-spec/test/get/20_fields.yaml45
-rw-r--r--rest-api-spec/test/get/30_parent.yaml45
-rw-r--r--rest-api-spec/test/get/40_routing.yaml41
-rw-r--r--rest-api-spec/test/get/55_parent_with_routing.yaml54
-rw-r--r--rest-api-spec/test/get/60_realtime_refresh.yaml49
-rw-r--r--rest-api-spec/test/get/70_source_filtering.yaml56
-rw-r--r--rest-api-spec/test/get/80_missing.yaml19
-rw-r--r--rest-api-spec/test/get/TODO.txt3
10 files changed, 364 insertions, 0 deletions
diff --git a/rest-api-spec/test/get/10_basic.yaml b/rest-api-spec/test/get/10_basic.yaml
new file mode 100644
index 0000000..0689f71
--- /dev/null
+++ b/rest-api-spec/test/get/10_basic.yaml
@@ -0,0 +1,31 @@
+---
+"Basic":
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 中文
+ body: { "foo": "Hello: 中文" }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 中文
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: 中文 }
+ - match: { _source: { foo: "Hello: 中文" } }
+
+ - do:
+ get:
+ index: test_1
+ type: _all
+ id: 中文
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: 中文 }
+ - match: { _source: { foo: "Hello: 中文" } }
diff --git a/rest-api-spec/test/get/15_default_values.yaml b/rest-api-spec/test/get/15_default_values.yaml
new file mode 100644
index 0000000..5e08112
--- /dev/null
+++ b/rest-api-spec/test/get/15_default_values.yaml
@@ -0,0 +1,21 @@
+---
+"Default values":
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ body: { "foo": "bar" }
+
+ - do:
+ get:
+ index: test_1
+ type: _all
+ id: 1
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: '1' }
+ - match: { _source: { foo: "bar" } }
+
diff --git a/rest-api-spec/test/get/20_fields.yaml b/rest-api-spec/test/get/20_fields.yaml
new file mode 100644
index 0000000..15530b8
--- /dev/null
+++ b/rest-api-spec/test/get/20_fields.yaml
@@ -0,0 +1,45 @@
+---
+"Fields":
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ body: { "foo": "bar", "count": 1 }
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: foo
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: '1' }
+ - match: { fields.foo: [bar] }
+ - is_false: _source
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: [foo, count]
+
+ - match: { fields.foo: [bar] }
+ - match: { fields.count: [1] }
+ - is_false: _source
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: [foo, count, _source]
+
+ - match: { fields.foo: [bar] }
+ - match: { fields.count: [1] }
+ - match: { _source.foo: bar }
+
+
diff --git a/rest-api-spec/test/get/30_parent.yaml b/rest-api-spec/test/get/30_parent.yaml
new file mode 100644
index 0000000..f7f31d0
--- /dev/null
+++ b/rest-api-spec/test/get/30_parent.yaml
@@ -0,0 +1,45 @@
+---
+setup:
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _parent: { type: "foo" }
+ - do:
+ cluster.health:
+ wait_for_status: yellow
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ parent: 中文
+ body: { foo: bar }
+
+---
+"Parent":
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 中文
+ fields: [_parent, _routing]
+
+ - match: { _id: "1"}
+ - match: { fields._parent: 中文 }
+ - match: { fields._routing: 中文}
+
+---
+"Parent omitted":
+ - do:
+ catch: request
+ get:
+ index: test_1
+ type: test
+ id: 1
+
diff --git a/rest-api-spec/test/get/40_routing.yaml b/rest-api-spec/test/get/40_routing.yaml
new file mode 100644
index 0000000..f909cb0
--- /dev/null
+++ b/rest-api-spec/test/get/40_routing.yaml
@@ -0,0 +1,41 @@
+---
+"Routing":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ settings:
+ index:
+ number_of_replicas: 0
+
+ - do:
+ cluster.health:
+ wait_for_status: green
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ routing: 5
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ routing: 5
+ fields: [_routing]
+
+ - match: { _id: "1"}
+ - match: { fields._routing: "5"}
+
+ - do:
+ catch: missing
+ get:
+ index: test_1
+ type: test
+ id: 1
+
diff --git a/rest-api-spec/test/get/55_parent_with_routing.yaml b/rest-api-spec/test/get/55_parent_with_routing.yaml
new file mode 100644
index 0000000..43d60f5
--- /dev/null
+++ b/rest-api-spec/test/get/55_parent_with_routing.yaml
@@ -0,0 +1,54 @@
+---
+"Parent with routing":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _parent: { type: "foo" }
+ settings:
+ number_of_replicas: 0
+
+ - do:
+ cluster.health:
+ wait_for_status: green
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ routing: 4
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ routing: 4
+ fields: [_parent, _routing]
+
+ - match: { _id: "1"}
+ - match: { fields._parent: "5"}
+ - match: { fields._routing: "4"}
+
+ - do:
+ catch: missing
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ routing: 4
+
diff --git a/rest-api-spec/test/get/60_realtime_refresh.yaml b/rest-api-spec/test/get/60_realtime_refresh.yaml
new file mode 100644
index 0000000..4631bed
--- /dev/null
+++ b/rest-api-spec/test/get/60_realtime_refresh.yaml
@@ -0,0 +1,49 @@
+---
+"Realtime Refresh":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ settings:
+ index:
+ refresh_interval: -1
+ number_of_replicas: 0
+
+ - do:
+ cluster.health:
+ wait_for_status: green
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ realtime: 1
+
+ - is_true: found
+
+ - do:
+ catch: missing
+ get:
+ index: test_1
+ type: test
+ id: 1
+ realtime: 0
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ realtime: 0
+ refresh: 1
+
+ - is_true: found
diff --git a/rest-api-spec/test/get/70_source_filtering.yaml b/rest-api-spec/test/get/70_source_filtering.yaml
new file mode 100644
index 0000000..03572bb
--- /dev/null
+++ b/rest-api-spec/test/get/70_source_filtering.yaml
@@ -0,0 +1,56 @@
+---
+"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
+
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: count
+ _source: true
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: "1" }
+ - match: { fields.count: [1] }
+ - match: { _source.include.field1: v1 }
diff --git a/rest-api-spec/test/get/80_missing.yaml b/rest-api-spec/test/get/80_missing.yaml
new file mode 100644
index 0000000..a60d113
--- /dev/null
+++ b/rest-api-spec/test/get/80_missing.yaml
@@ -0,0 +1,19 @@
+---
+"Missing document with catch":
+
+ - do:
+ catch: missing
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+---
+"Missing document with ignore":
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ ignore: 404
diff --git a/rest-api-spec/test/get/TODO.txt b/rest-api-spec/test/get/TODO.txt
new file mode 100644
index 0000000..340ff57
--- /dev/null
+++ b/rest-api-spec/test/get/TODO.txt
@@ -0,0 +1,3 @@
+Tests missing for:
+
+# preference