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

The method searchable is not indexing a document #65

Open
martijnderidder opened this issue Oct 31, 2024 · 1 comment
Open

The method searchable is not indexing a document #65

martijnderidder opened this issue Oct 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@martijnderidder
Copy link

martijnderidder commented Oct 31, 2024

Software Version
PHP 8.2.19
Elasticsearch 8.3.3
Laravel 10.48.22
Laravel Scout 9.8.1

Describe the bug
I am updating some data of a model, i also have a observer which specifies the status based on a few criteria. Because i dont want to create a loop, i use the saveQuietly method. The data gets saved in the database, but not in Elasticsearch (ok i get it, because i disabled all events i guess). But i want to use a method like ->searchable() or something to index my new data to Elasticsearch.

Is there a way to force the data to be send again to Elasticsearch? I cannot use the ->touch() method, because this will create a loop because the updated observer is getting fired again.

Expected behavior
I would expect that the method ->searchable() would reindex the data again. But it look liks it doenst do anything.

@martijnderidder martijnderidder added the bug Something isn't working label Oct 31, 2024
@babenkoivan
Copy link
Owner

Hey @martijnderidder, I don't see why the searchable method would not work. I've just tried the code below and it seems to be working fine:

$source = factory(Book::class)->make();
$source->saveQuietly();
$source->searchable(); 

$found = Book::search()->get(); // returns the created object

Please ensure that the queue workers are running if you use queues and that your code looks similar to the above.

If you still don't see changes in Elasticsearch, make sure that the mapping for the fields you index is configured properly and try to debug the code step by step to see if this method is being called.

I hope this helps 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@martijnderidder @babenkoivan and others