@@ -130,6 +130,156 @@ public async Task TestMultipleOperations()
130
130
Assert . That ( multiQueri2 . Results . ElementAt ( 0 ) . Hits , Has . Exactly ( 2 ) . Items ) ;
131
131
Assert . That ( multiQueri2 . Results . ElementAt ( 1 ) . Hits , Is . Empty ) ;
132
132
}
133
+
134
+ [ Test ]
135
+ public async Task TestMultipleOperationsUsingQueryMultiIndices ( )
136
+ {
137
+ var objectsToSave = new List < BatchOperation < MultipleOperationClass > >
138
+ {
139
+ new BatchOperation < MultipleOperationClass >
140
+ {
141
+ IndexName = _indexName1 ,
142
+ Action = BatchActionType . AddObject ,
143
+ Body = new MultipleOperationClass { Firstname = "Jimmie" }
144
+ } ,
145
+ new BatchOperation < MultipleOperationClass >
146
+ {
147
+ IndexName = _indexName1 ,
148
+ Action = BatchActionType . AddObject ,
149
+ Body = new MultipleOperationClass { Firstname = "Jimmie" }
150
+ } ,
151
+ new BatchOperation < MultipleOperationClass >
152
+ {
153
+ IndexName = _indexName2 ,
154
+ Action = BatchActionType . AddObject ,
155
+ Body = new MultipleOperationClass { Firstname = "Jimmie" }
156
+ } ,
157
+ new BatchOperation < MultipleOperationClass >
158
+ {
159
+ IndexName = _indexName2 ,
160
+ Action = BatchActionType . AddObject ,
161
+ Body = new MultipleOperationClass { Firstname = "Jimmie" }
162
+ }
163
+ } ;
164
+
165
+ var saveMultiple = await BaseTest . SearchClient . MultipleBatchAsync ( objectsToSave ) ;
166
+ saveMultiple . Wait ( ) ;
167
+
168
+ var objectsToRetrieve = new List < MultipleGetObject >
169
+ {
170
+ new MultipleGetObject { IndexName = _indexName1 , ObjectID = saveMultiple . ObjectIDs . ElementAt ( 0 ) } ,
171
+ new MultipleGetObject { IndexName = _indexName1 , ObjectID = saveMultiple . ObjectIDs . ElementAt ( 1 ) } ,
172
+ new MultipleGetObject { IndexName = _indexName2 , ObjectID = saveMultiple . ObjectIDs . ElementAt ( 2 ) } ,
173
+ new MultipleGetObject { IndexName = _indexName2 , ObjectID = saveMultiple . ObjectIDs . ElementAt ( 3 ) }
174
+ } ;
175
+
176
+ var multipleGet =
177
+ await BaseTest . SearchClient . MultipleGetObjectsAsync < MultipleOperationClass > ( objectsToRetrieve ) ;
178
+ Assert . That ( multipleGet . Results , Has . Exactly ( 4 ) . Items ) ;
179
+ Assert . True ( multipleGet . Results . All ( x => x . Firstname . Equals ( "Jimmie" ) ) ) ;
180
+
181
+ for ( int i = 0 ; i < 4 ; i ++ )
182
+ {
183
+ Assert . True ( multipleGet . Results . ElementAt ( i ) . ObjectID == saveMultiple . ObjectIDs . ElementAt ( i ) ) ;
184
+ }
185
+
186
+ List < QueryMultiIndices > multipleSearch = new List < QueryMultiIndices >
187
+ {
188
+ new ( _indexName1 ) { HitsPerPage = 2 } ,
189
+ new ( _indexName2 ) { HitsPerPage = 2 } ,
190
+ } ;
191
+
192
+ MultipleQueriesRequest request = new MultipleQueriesRequest
193
+ {
194
+ Strategy = StrategyType . None ,
195
+ Requests = multipleSearch
196
+ } ;
197
+
198
+ MultipleQueriesRequest request2 = new MultipleQueriesRequest
199
+ {
200
+ Strategy = StrategyType . StopIfEnoughMatches ,
201
+ Requests = multipleSearch
202
+ } ;
203
+
204
+ var multiQueri = await BaseTest . SearchClient . MultipleQueriesAsync < MultipleOperationClass > ( request ) ;
205
+ var multiQueri2 = await BaseTest . SearchClient . MultipleQueriesAsync < MultipleOperationClass > ( request2 ) ;
206
+
207
+ Assert . That ( multiQueri . Results , Has . Exactly ( 2 ) . Items ) ;
208
+ Assert . That ( multiQueri . Results . ElementAt ( 0 ) . Hits , Has . Exactly ( 2 ) . Items ) ;
209
+ Assert . That ( multiQueri . Results . ElementAt ( 1 ) . Hits , Has . Exactly ( 2 ) . Items ) ;
210
+
211
+ Assert . That ( multiQueri2 . Results , Has . Exactly ( 2 ) . Items ) ;
212
+ Assert . That ( multiQueri2 . Results . ElementAt ( 0 ) . Hits , Has . Exactly ( 2 ) . Items ) ;
213
+ Assert . That ( multiQueri2 . Results . ElementAt ( 1 ) . Hits , Is . Empty ) ;
214
+ }
215
+
216
+ [ Test ]
217
+ public async Task TestMultipleQueriesWithQueryMultiIndicesObject ( )
218
+ {
219
+ var objectsToSave = new List < BatchOperation < MultipleOperationClass > >
220
+ {
221
+ new BatchOperation < MultipleOperationClass >
222
+ {
223
+ IndexName = _indexName3 ,
224
+ Action = BatchActionType . AddObject ,
225
+ Body = new MultipleOperationClass { Firstname = "Jimmie" }
226
+ } ,
227
+ } ;
228
+
229
+ var saveMultiple = await BaseTest . SearchClient . MultipleBatchAsync ( objectsToSave ) ;
230
+ saveMultiple . Wait ( ) ;
231
+
232
+ var query = new Query ( )
233
+ {
234
+ Explain = new List < string > { "test1" , "test2" } ,
235
+ AroundPrecision = new List < AroundPrecision >
236
+ {
237
+ new ( ) { From = 0 , Value = 1 } ,
238
+ new ( ) { From = 100 , Value = 10 }
239
+ } ,
240
+ CustomParameters = new Dictionary < string , object > ( )
241
+ {
242
+ { "hitsPerPage" , 10 }
243
+ } ,
244
+ TagFilters = new List < IEnumerable < string > > ( )
245
+ {
246
+ new List < string > { "one" , "two" } ,
247
+ new List < string > { "one-two" , "two-two" }
248
+ }
249
+ } ;
250
+
251
+ var request = new MultipleQueriesRequest
252
+ {
253
+ Requests = new List < QueryMultiIndices > {
254
+ new QueryMultiIndices ( _indexName3 )
255
+ {
256
+ Explain = new List < string > { "test1" , "test2" } ,
257
+ AroundPrecision = new List < AroundPrecision >
258
+ {
259
+ new ( ) { From = 0 , Value = 1 } ,
260
+ new ( ) { From = 100 , Value = 10 }
261
+ } ,
262
+ CustomParameters = new Dictionary < string , object > ( )
263
+ {
264
+ { "hitsPerPage" , 10 }
265
+ } ,
266
+ TagFilters = new List < IEnumerable < string > > ( )
267
+ {
268
+ new List < string > { "one" , "two" } ,
269
+ new List < string > { "one-two" , "two-two" }
270
+ }
271
+ }
272
+ }
273
+ } ;
274
+
275
+ var index = BaseTest . SearchClient . InitIndex ( _indexName3 ) ;
276
+
277
+ var responseSearch = index . Search < MultipleOperationClass > ( query ) ;
278
+ var responseMultipleQueries = BaseTest . SearchClient . MultipleQueries < MultipleOperationClass > ( request ) ;
279
+
280
+ Assert . AreEqual ( responseSearch . Params , responseMultipleQueries . Results . First ( ) . Params ) ;
281
+ }
282
+
133
283
[ Test ]
134
284
public async Task TestMultipleQueriesFacet ( )
135
285
{
0 commit comments