I have a question: I need to get communication with algolia, but i cannot get that work, since of leak of documentation. I have symfony 5.4 but algora docs provide only for version 4, second when I trying to get some of my entities indexed i get stuck at the point when i have to provide entityManager
which suppose to implement ObjectManager
, but that one it is not wired in the service. And how many people suggest we should not use this directly and use EntityManagerInteface
instead. So how i have to index my Entity?
What i did:
composer require algolia/search-bundle
Added credentials:
ALGOLIA_APP_ID="U1RFIHY01W"
ALGOLIA_API_KEY="YourAPIKey"
Trying to index in the controller for testing:
public function searchPosts(Post $post, ManagerRegistry $em): JsonResponse
{
$posts = $this->postRepository->searchPosts('82819');
$postsArray = [];
/**@var Post $post */
foreach ($posts as $post){
$postsArray = $post->normalize();
}
$this->searchService->index($em->getManager(), $postsArray);
return new JsonResponse($this->searchService->getConfiguration());
}
Right now since i use ManagerRegestry
i get an error:
get_class(): Argument #1 ($object) must be of type object, int given
Can you help me work around? Thank you