@@ -53,6 +53,7 @@ func (s *elasticTestSuite) TestSimple(c *C) {
53
53
54
54
r , err := s .c .Get (index , docType , "1" )
55
55
c .Assert (err , IsNil )
56
+ c .Assert (r .Code , Equals , 200 )
56
57
c .Assert (r .ID , Equals , "1" )
57
58
58
59
err = s .c .Delete (index , docType , "1" )
@@ -78,6 +79,7 @@ func (s *elasticTestSuite) TestSimple(c *C) {
78
79
79
80
resp , err := s .c .IndexTypeBulk (index , docType , items )
80
81
c .Assert (err , IsNil )
82
+ c .Assert (resp .Code , Equals , 200 )
81
83
c .Assert (resp .Errors , Equals , false )
82
84
83
85
for i := 0 ; i < 10 ; i ++ {
@@ -90,16 +92,26 @@ func (s *elasticTestSuite) TestSimple(c *C) {
90
92
91
93
resp , err = s .c .IndexTypeBulk (index , docType , items )
92
94
c .Assert (err , IsNil )
95
+ c .Assert (resp .Code , Equals , 200 )
93
96
c .Assert (resp .Errors , Equals , false )
94
97
}
95
98
96
99
// this requires a parent setting in _mapping
97
100
func (s * elasticTestSuite ) TestParent (c * C ) {
98
101
index := "dummy"
99
102
docType := "comment"
103
+ ParentType := "parent"
100
104
105
+ mapping := map [string ]interface {}{
106
+ docType : map [string ]interface {}{
107
+ "_parent" : map [string ]string {"type" : ParentType },
108
+ },
109
+ }
110
+ err := s .c .CreateMapping (index , docType , mapping )
111
+ c .Assert (err , IsNil )
112
+
101
113
items := make ([]* BulkRequest , 10 )
102
-
114
+
103
115
for i := 0 ; i < 10 ; i ++ {
104
116
id := fmt .Sprintf ("%d" , i )
105
117
req := new (BulkRequest )
@@ -112,16 +124,20 @@ func (s *elasticTestSuite) TestParent(c *C) {
112
124
113
125
resp , err := s .c .IndexTypeBulk (index , docType , items )
114
126
c .Assert (err , IsNil )
127
+ c .Assert (resp .Code , Equals , 200 )
115
128
c .Assert (resp .Errors , Equals , false )
116
-
117
129
for i := 0 ; i < 10 ; i ++ {
118
130
id := fmt .Sprintf ("%d" , i )
119
131
req := new (BulkRequest )
132
+ req .Index = index
133
+ req .Type = docType
120
134
req .Action = ActionDelete
121
135
req .ID = id
136
+ req .Parent = "1"
122
137
items [i ] = req
123
138
}
124
- resp , err = s .c .IndexTypeBulk ( index , docType , items )
139
+ resp , err = s .c .Bulk ( items )
125
140
c .Assert (err , IsNil )
141
+ c .Assert (resp .Code , Equals , 200 )
126
142
c .Assert (resp .Errors , Equals , false )
127
143
}
0 commit comments