Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import of Mongo ODM entities fails #311

Closed
Evoolo opened this issue Dec 15, 2023 · 4 comments
Closed

Import of Mongo ODM entities fails #311

Evoolo opened this issue Dec 15, 2023 · 4 comments

Comments

@Evoolo
Copy link

Evoolo commented Dec 15, 2023

Description
I added some entities to my meilisearch config and then run php bin/console meilisearch:import.
All MySQL entities are getting imported correctly. As soon as I reach the first mongo-odm entity, it fails with

In MeilisearchImportCommand.php line 115: Call to a member function getRepository() on null

While this package loads only the Doctrine\Persistence\ManagerRegistry wich can not be used for mongo-aod, I think this package is not compatible with the mongo-odm implementation.

Also when I try to persist a new entity, I get this error:

{
"code": 500,
"message": "Meilisearch\Bundle\SearchableEntity::__construct(): Argument #3 ($entityMetadata) must be of type Doctrine\ORM\Mapping\ClassMetadata, Doctrine\ODM\MongoDB\Mapping\ClassMetadata given, called in /home/vagrant/code/chgtwy_api/vendor/meilisearch/search-bundle/src/Services/MeilisearchService.php on line 318"
}

Expected behavior
creating a search index for all entities

Current behavior
only creates an index for MySQL entities and throws an error on mongo-odm entities

In MeilisearchImportCommand.php line 115: Call to a member function getRepository() on null

Screenshots or Logs

// config/packages/meilisearch.yaml
meilisearch:
    url: '%env(MEILISEARCH_URL)%' # URL of the Meilisearch server (mandatory)
    api_key: '%env(MEILISEARCH_API_KEY)%' # API key to access the Meilisearch server (mandatory)
    prefix: '%env(MEILISEARCH_PREFIX)%'
    indices:
        - name: account
          class: App\Entity\Account\Account
          enable_serializer_groups: true
        - name: log_request
          class: App\Entity\LogRequest
          enable_serializer_groups: true
        - name: bsc_webhook
          class: App\Document\BinanceSmartChain\Webhook
          enable_serializer_groups: true
        - name: bsc_notification
          class: App\Document\BinanceSmartChain\Notification
          enable_serializer_groups: true
<?php

namespace App\Document\BinanceSmartChain;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

#[MongoDb\Document(db: 'IPN', collection: 'ipn_bsc_main_send', repositoryClass: \App\Repository\BinanceSmartChain\NotificationRepository::class)]
class Notification
{

    #[MongoDB\Id]
    protected $id;

    #[MongoDB\Field(type: 'string')]
    protected $txid;

    #[MongoDB\Field(type: 'string')]
    protected $webhook_id;

    #[MongoDB\Field(type: 'string')]
    protected $type;
...

Environment (please complete the following information):

  • OS: Ubuntu 22.04
  • Meilisearch version: v1.5.0
  • meilisearch-symfony version: v1.0.0
@norkunas
Copy link
Collaborator

norkunas commented Dec 15, 2023

Hello,

ODM is currently not supported.

Sorry, that README states otherwise 😞 cc @brunoocasali why is that?

@Evoolo
Copy link
Author

Evoolo commented Dec 15, 2023

Okay thank you for the clarification. I will inspect all classes and do some PRs if I can manage to get it work.

@norkunas
Copy link
Collaborator

This needs more refactor than it looks - we need to support indexing any data, for example like requested in #302,
then this will open door for simple integration with ODM

@brunoocasali
Copy link
Member

Hi @norkunas, that statement in the README comes from the initial commit made by the original author of this library, but indeed I don't think we support ODM today.
However, I can find some references to Mongo in the source code.

I will push a PR to remove that statement ;)

brunoocasali added a commit that referenced this issue Dec 15, 2023
meili-bors bot added a commit that referenced this issue Dec 15, 2023
312: Remove ODM support from README r=brunoocasali a=brunoocasali

Related to #311

`@norkunas` feel free to merge when you review ;)

Co-authored-by: Bruno Casali <[email protected]>
@Evoolo Evoolo closed this as completed Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants