File tree 3 files changed +38
-0
lines changed
test/lib/Elastica/Test/Query
3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1
1
CHANGES
2
2
3
+ 2015-04-23
4
+ - Fix empty bool query to act as match all query #817
5
+
3
6
2015-04-15
4
7
- deleteByQuery() implemented in Elastica\Index
5
8
Original file line number Diff line number Diff line change @@ -90,4 +90,18 @@ public function setMinimumNumberShouldMatch($minimumNumberShouldMatch)
90
90
{
91
91
return $ this ->setParam ('minimum_number_should_match ' , $ minimumNumberShouldMatch );
92
92
}
93
+
94
+ /**
95
+ * Converts array to an object in case no queries are added
96
+ *
97
+ * @return array
98
+ */
99
+ public function toArray ()
100
+ {
101
+ if (empty ($ this ->_params )) {
102
+ $ this ->_params = new \stdClass ();
103
+ }
104
+ return parent ::toArray ();
105
+ }
106
+
93
107
}
Original file line number Diff line number Diff line change @@ -111,4 +111,25 @@ public function testSearch()
111
111
112
112
$ this ->assertEquals (0 , $ resultSet ->count ());
113
113
}
114
+
115
+ public function testEmptyBoolQuery () {
116
+ $ index = $ this ->_createIndex ();
117
+ $ type = new Type ($ index , 'test ' );
118
+
119
+ $ docNumber = 3 ;
120
+ for ($ i = 0 ; $ i < $ docNumber ; $ i ++) {
121
+ $ doc =
new Document (
$ i,
array (
'email ' =>
'[email protected] ' ));
122
+ $ type ->addDocument ($ doc );
123
+ }
124
+
125
+ $ index ->refresh ();
126
+
127
+ $ boolQuery = new Bool ();
128
+
129
+ $ resultSet = $ type ->search ($ boolQuery );
130
+
131
+ $ this ->assertEquals ($ resultSet ->count (), $ docNumber );
132
+
133
+
134
+ }
114
135
}
You can’t perform that action at this time.
0 commit comments