Skip to content

Commit dc8a4d2

Browse files
authored
refactor(elasticsearch): add stateOptions and change how to configure elasticsearch (api-platform#5297)
This commit introduce a new stateOptions property on ApiResource and operations. This perperty will allow to configure elasticsearch, and soon doctrine ORM and ODM. Now, we can use elasticsearch by providing directly an elasticsearch provider at the operation (Get or GetCollection). The old way of using elasticsearch has been deprecated.
1 parent 3bbc61e commit dc8a4d2

File tree

53 files changed

+2243
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2243
-134
lines changed

features/elasticsearch/match_filter.feature

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,216 @@ Feature: Match filter on collections from Elasticsearch
216216
}
217217
}
218218
"""
219+
220+
Scenario: Match filter on a text property with new elasticsearch operations
221+
When I send a "GET" request to "/books?message=Good%20job"
222+
Then the response status code should be 200
223+
And the response should be in JSON
224+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
225+
And the JSON should be valid according to this schema:
226+
"""
227+
{
228+
"type": "object",
229+
"properties": {
230+
"@context": {"pattern": "^/contexts/Book$"},
231+
"@id": {"pattern": "^/books$"},
232+
"@type": {"pattern": "^hydra:Collection$"},
233+
"hydra:member": {
234+
"type": "array",
235+
"additionalItems": false,
236+
"maxItems": 2,
237+
"minItems": 2,
238+
"items": [
239+
{
240+
"type": "object",
241+
"properties": {
242+
"@id": {
243+
"type": "string",
244+
"pattern": "^/books/7cdadcda-3fb5-4312-9e32-72acba323cc0$"
245+
}
246+
}
247+
},
248+
{
249+
"type": "object",
250+
"properties": {
251+
"@id": {
252+
"type": "string",
253+
"pattern": "^/books/f91bca21-b5f8-405b-9b08-d5a5dc476a92$"
254+
}
255+
}
256+
}
257+
]
258+
},
259+
"hydra:view": {
260+
"type": "object",
261+
"properties": {
262+
"@id": {"pattern": "^/books\\?message=Good%20job$"},
263+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
264+
}
265+
}
266+
}
267+
}
268+
"""
269+
270+
Scenario: Match filter on a text property with new elasticsearch operations
271+
When I send a "GET" request to "/books?message%5B%5D=Good%20job&message%5B%5D=run"
272+
Then the response status code should be 200
273+
And the response should be in JSON
274+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
275+
And the JSON should be valid according to this schema:
276+
"""
277+
{
278+
"type": "object",
279+
"properties": {
280+
"@context": {"pattern": "^/contexts/Book$"},
281+
"@id": {"pattern": "^/books$"},
282+
"@type": {"pattern": "^hydra:Collection$"},
283+
"hydra:member": {
284+
"type": "array",
285+
"additionalItems": false,
286+
"maxItems": 3,
287+
"minItems": 3,
288+
"items": [
289+
{
290+
"type": "object",
291+
"properties": {
292+
"@id": {
293+
"type": "string",
294+
"pattern": "^/books/6d82a76c-8ba2-4e78-9ab3-6a456e4470c3$"
295+
}
296+
}
297+
},
298+
{
299+
"type": "object",
300+
"properties": {
301+
"@id": {
302+
"type": "string",
303+
"pattern": "^/books/7cdadcda-3fb5-4312-9e32-72acba323cc0$"
304+
}
305+
}
306+
},
307+
{
308+
"type": "object",
309+
"properties": {
310+
"@id": {
311+
"type": "string",
312+
"pattern": "^/books/9de3308c-6f82-4a57-a33c-4e3cd5d5a3f6$"
313+
}
314+
}
315+
}
316+
]
317+
},
318+
"hydra:totalItem": {
319+
"type": "string",
320+
"pattern": "^4$"
321+
},
322+
"hydra:view": {
323+
"type": "object",
324+
"properties": {
325+
"@id": {"pattern": "^/books\\?message%5B%5D=Good%20job&message%5B%5D=run&page=1$"},
326+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
327+
}
328+
}
329+
}
330+
}
331+
"""
332+
333+
Scenario: Match filter on a nested property of text type with new elasticsearch operations
334+
When I send a "GET" request to "/books?library.firstName=Caroline"
335+
Then the response status code should be 200
336+
And the response should be in JSON
337+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
338+
And the JSON should be valid according to this schema:
339+
"""
340+
{
341+
"type": "object",
342+
"properties": {
343+
"@context": {"pattern": "^/contexts/Book$"},
344+
"@id": {"pattern": "^/books$"},
345+
"@type": {"pattern": "^hydra:Collection$"},
346+
"hydra:member": {
347+
"type": "array",
348+
"additionalItems": false,
349+
"maxItems": 2,
350+
"minItems": 2,
351+
"items": [
352+
{
353+
"type": "object",
354+
"properties": {
355+
"@id": {
356+
"type": "string",
357+
"pattern": "^/books/6d82a76c-8ba2-4e78-9ab3-6a456e4470c3$"
358+
}
359+
}
360+
},
361+
{
362+
"type": "object",
363+
"properties": {
364+
"@id": {
365+
"type": "string",
366+
"pattern": "^/books/f91bca21-b5f8-405b-9b08-d5a5dc476a92$"
367+
}
368+
}
369+
}
370+
]
371+
},
372+
"hydra:view": {
373+
"type": "object",
374+
"properties": {
375+
"@id": {"pattern": "^/books\\?library.firstName=Caroline$"},
376+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
377+
}
378+
}
379+
}
380+
}
381+
"""
382+
383+
Scenario: Combining match filters on properties of text type and a nested property of text type with new elasticsearch operations
384+
When I send a "GET" request to "/books?message%5B%5D=Good%20job&message%5B%5D=run&library.firstName=Caroline"
385+
Then the response status code should be 200
386+
And the response should be in JSON
387+
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
388+
And the JSON should be valid according to this schema:
389+
"""
390+
{
391+
"type": "object",
392+
"properties": {
393+
"@context": {"pattern": "^/contexts/Book$"},
394+
"@id": {"pattern": "^/books$"},
395+
"@type": {"pattern": "^hydra:Collection$"},
396+
"hydra:member": {
397+
"type": "array",
398+
"additionalItems": false,
399+
"maxItems": 2,
400+
"minItems": 2,
401+
"items": [
402+
{
403+
"type": "object",
404+
"properties": {
405+
"@id": {
406+
"type": "string",
407+
"pattern": "^/books/6d82a76c-8ba2-4e78-9ab3-6a456e4470c3$"
408+
}
409+
}
410+
},
411+
{
412+
"type": "object",
413+
"properties": {
414+
"@id": {
415+
"type": "string",
416+
"pattern": "^/books/f91bca21-b5f8-405b-9b08-d5a5dc476a92$"
417+
}
418+
}
419+
}
420+
]
421+
},
422+
"hydra:view": {
423+
"type": "object",
424+
"properties": {
425+
"@id": {"pattern": "^/books\\?message%5B%5D=Good%20job&message%5B%5D=run&library.firstName=Caroline$"},
426+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
427+
}
428+
}
429+
}
430+
}
431+
"""

0 commit comments

Comments
 (0)