Open ghost opened 3 years ago
@joergmoldenhauer could you try with:
fos_elastica:
clients:
default: { url: '%env(ELASTICSEARCH_URL)%' }
indexes:
my_index:
use_alias: true
properties:
my_property:
type: keyword
persistence:
provider:
service: app.search_provider.my_provider
listener: false
That should avoid passing in the listener configuration method.
That worked. Thank you.
I am also having some problems with my custom provider like described here: https://stackoverflow.com/questions/66693334/fos-elastica-how-can-i-populate-an-index-without-doctrine
Do you have an idea?
Do you have an idea?
@joergmoldenhauer not for the moment, I would have to investigate to understand what breaks ;)
I think I need a DTO to use as a model. The following code works:
# config/packages/fos_elastica.yaml
fos_elastica:
clients:
default: { url: '%env(ELASTICSEARCH_URL)%' }
indexes:
my_index:
use_alias: true
properties:
myProperty:
type: keyword
persistence:
model: App\Entity\MyEntity
provider:
service: app.search_provider.my_provider
listener: false
// src/Entity
namespace App\Entity;
final class MyEntity
{
public int $id;
public string $myProperty;
}
// src/SearchProvider/MyProvider.php
namespace App\SearchProvider;
use App\Entity\MyEntity;
use FOS\ElasticaBundle\Provider\PagerfantaPager;
use FOS\ElasticaBundle\Provider\PagerInterface;
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Pagerfanta;
final class MyProvider implements PagerProviderInterface
{
public function provide(array $options = []): PagerInterface
{
$myEntity = new MyEntity();
$myEntity->id = 1;
$myEntity->myProperty = 'test';
return new PagerfantaPager(new Pagerfanta(new ArrayAdapter([$myEntity])));
}
}
But I still have a problem with indexing a large set of data. I think I can not create an array with millions of elements.
I do not have Doctrine installed in my Symfony application. I use FOSElasticaBundle 6.0.x-dev with the following configuration:
When I clear the cache or try to populate the index I get the following error:
When I install Doctrine I do not get this error. Can't I use the bundle without Doctrine?