Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions core/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,45 @@ final class SwaggerDecorator implements NormalizerInterface
```

That's it: your route is gone!

## Disabling ElasticSearch on Operations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this docs in elasticsearch.md instead please? It will be easier to discover.

Also, can you add a blank line after the title?

After enabling [Elasticsearch Support](elasticsearch.md) in your project, there may come a time you would prefer not to read your data from your Elasticsearch server and would rather fetch your data directly from your database. To achieve this, you can pass in a parameter to your api operation with the value `elasticsearch: true`.
For example:

```php
<?php
// src/Entity/Place.php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Controller\GetWeather;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*
* @ApiResource(
* itemOperations={
* "get": {"elasticsearch": false},
* "put",
* "delete",
* "get_weather": {
* "method": "GET",
* "path": "/places/{id}/weather",
* "controller": GetWeather::class
* }
* },
* collectionOperations={
* "get" : {
* "elasticsearch": false
* },
* "post"
* }
* )
*/
class Place
{
// ...
}
```