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

Indexing plain objects without entitymanager #302

Open
ToshY opened this issue Nov 5, 2023 · 7 comments
Open

Indexing plain objects without entitymanager #302

ToshY opened this issue Nov 5, 2023 · 7 comments

Comments

@ToshY
Copy link

ToshY commented Nov 5, 2023

Description
I've been briefly looking through the Wiki and I cannot find an example that shows if it's possible to use plain objects/models/DTOs and index them with this bundle. I've found in the code that the SearchService can perform rawSearch, which I assume works for any non-entities as well (?), but I don't see a similar indexing method for this kind of "raw" indexing.

So my question follows: is indexing of plain objects supported?

Basic example

  • If it's already possible with the SearchService to index plain objects, I'd appreciate an example (and update the Wiki accordingly).
  • If this is not possible, maybe I'm better of with using meilisearch-php directly?

Other
I'm new to Meilisearch 🙂

@norkunas
Copy link
Collaborator

norkunas commented Nov 5, 2023

Currently not, but I've plans to implement this in future

@ToshY
Copy link
Author

ToshY commented Nov 5, 2023

Hey @norkunas 👋

Thanks for the quick response. I'll be eagerly waiting until then 👌

@tacman
Copy link

tacman commented Jun 27, 2024

I, too, would like to see this bundle de-coupled from the EntityManager. I use the meilisearch-php library to index plain objects, as I'm working on a project to index csv files and it bypasses doctrine altogether.

@tacman
Copy link

tacman commented Jun 27, 2024

https://symfony.com/blog/migrating-symfony-com-search-engine-to-meilisearch

There is a Meilisearch Symfony bundle, but we don't use it because ... it's mainly focused on indexing Doctrine entities/documents.

Symfony documentation is built with the symfony-tools/docs-builder, which parses RST documents and outputs JSON files with a certain structure (title, body, TOC, pagination, etc.) That's why we used the Meilisearch PHP integration [instead of the bundle]

I think this situation is very common, to want to index data without using Doctrine. While it's a cool feature of the bundle to have a listener and updating the meili index in the background when a doctrine entity has been changed, I don't think is should be the only way to update an index.

In fact, I would use this bundle just for the still-unmerged debug toolbar. Currently I use the Symfony HTTP client to update meili, so I can debug the HTTP requests, but a dedicated toolbar would rock.

@norkunas
Copy link
Collaborator

I still pursue it, just need more time

@ToshY
Copy link
Author

ToshY commented Jun 27, 2024

@tacman You might be interested in checking out schranz-search/schranz-search, which also has a Meilisearch adapter. I've been using that bundle since I've created this issue, and with the addition of some custom code to make the Meilisearch Client able to use "filters", it works really well.

@tacman
Copy link

tacman commented Jun 27, 2024

@ToshY Cool, thanks, I'll check it out.

I have a meilisearch service in a bundle that integrates datatables.net with api-platform, it works great but I now need the same functionality in another bundle. So I'm trying to extract my service which has no application-specific logic, just a wrapper around creating indexes including some async stuff. Like getting stats for the index, which obviously can't be done until the index is finished.

    public function waitUntilFinished(Indexes $index, SymfonyStyle $io = null): array
    {
        do {
            $index->fetchInfo();
            $info = $index->fetchInfo();
            $stats = $index->stats();
            $isIndexing = $stats['isIndexing'];
            $indexName = $index->getUid();
            if ($this->logger) {
                $this->logger->info(sprintf("\n%s is %s with %d documents",
                    $indexName, $isIndexing ? 'indexing' : 'ready', $stats['numberOfDocuments']));
            }
            if ($isIndexing) {
                sleep(1);
            }
        } while ($isIndexing);
        return $stats;
    }

Anyway, just brainstorming, I'd love to drop my service and use this bundle or the package you recommended.

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