I can't index my documents (they are ok at Algolia) #36
Comments
Hello @elfeffe, This is hard to help you without more information. if you log your meilisearch instance did you get:
If you have use of |
I’m using MongoDb. I think the key is _id |
I can't understand what you mean with
Let me know what do you want me to try |
If I try
I get But then I do
|
Hello @elfeffe You can always check an update status, most of the times MeiliSearch will tell you what the error was, in case the update failed. You can check: Get an update status And for the last example you can try curl -X GET 'http://localhost:7700/indexes/local_product/updates/31' which should give you more information on what is happening. |
When you have created your index
Can you also try by comment the toSearchableArray(), I don't think this is the problem here, but it cost nothing to try. |
I have removed toSearchableArray() Then doing
Nothing, when I do I just get one document, the one indexed using
Is there any log that I can check? |
When you import your data, did you get something like this: shok@pop-os:~/web/blog$ php artisan scout:import "App\Models\Post"
Imported [App\Models\Post] models up to ID: 100
All [App\Models\Post] records have been imported. logs are located Did you set queue => true in |
I have tried with both true and false for queues. Always I get Imported [App\Models\Product] models up to ID: 5eea4b314c80095faf5be593 But there are no ducuments. With all the same settings, Algolia is indexing my documents. |
This is related to MongoDB, because Users model is MySQL and works. It will be great if i can ee some logs from MS, it is sad if Algolia supports it but not Meilisearch. |
I can try to dig the problem, but I need your help on how I can install mongoDB with laravel |
As for now, MeiliSearch logs are directly printed to stdout, so it depends on where you are running your MeiliSearch instance. Where is it running? I opened an issue for discussing persistent logs in MeiliSearch here: meilisearch/meilisearch#898 @elfeffe did you check the update status as I suggested in previous comments? If the documents were successfully sent to MeilISearch and you got a status ID, you will very probably find inside that update status the information about what is the problem when MeilISearch tries to index. Try this: #36 (comment) |
Look at this
That works, but
"5eea4bd94c80095faf5be787" is a MongoDB _id
I think that JSON is valid, there is some problem with MS and custom Key. |
After some tries I think the letters are the problem, MS doesn't accept letters on the id. But Laravel let you put letters there. |
Yes, you just need to send that as a string, surrounded by double quotes |
It will work with |
But I don't control how your Scout extension send it 🙂 |
Even doing this
It doesn't work, I think this engine must handle string ids |
do the same thing in toSearchableArray()
I don't know what you have set as key |
That works |
One last thing. |
Indeed, the MeiliSearch API does not handle this feature yet.
The problem you had comes from the JSON validity. Even Algolia API does not accept invalid JSON: sending a number with letters without quoting it ( See the Algolia dashboard: Maybe the Algolia's Laravel SDK transforms your number with letters into a string and that's why you didn't have any failure 🙂
So maybe |
Yes, in both cases I'm speaking about this Scout Engine, we are in the Scout integration here. The same with Id with letters, I understand that JSOn is malformed, but the Scout engine shpuld control that before it fails. |
Ok ok wasn't sure to understand 😉 They could be nice features to implement then! 🙂 Edit: we should think if we implement that in the meilisearch-php or in the meilisearch-laravel-scout package. |
@curquiza If we implement it in scout I guess the symfony(and others framework implementation) should also implement it (may be it's already the case). So it might be better to have it in the SDK instead ? I'm not sure scout implement it for Algolia, I think this is handle by the Algolia PHP SDK, I will check this when I have a bit of free time. |
@shokme, you're right, it might be smarter to do it in the PHP SDK rather in the laravel-scout integration. |
So, after investigating the whole thing. I have started by creating my index. create a model <?php
namespace App;
use Jenssegers\Mongodb\Eloquent\Model;
use Laravel\Scout\Searchable;
class Car extends Model
{
use Searchable;
public function getScoutKey() // not required if this is already your primary key
{
return $this->_id;
}
public function getScoutKeyName() // not required if this is already your primary key
{
return '_id';
}
} creating a new car $car = new App\Car();
$car->name = 'mustang';
$car->constructor = 'ford';
$car->type = 'muscle';
$car->horses = 280;
$car->save(); The model was send to meilisearch without any problem ! {
"status": "processed",
"updateId": 1,
"type": {
"name": "DocumentsAddition",
"number": 1
},
"duration": 0.005275826,
"enqueuedAt": "2020-08-29T17:43:55.104917708Z",
"processedAt": "2020-08-29T17:43:55.121602037Z"
} When doing a search I get the correct result App\Car::search('mustang')->get(); [
{
"_id": "5f4a93dbd9668370086c7752",
"name": "mustang",
"constructor": "ford",
"type": "muscle",
"horses": 280,
"updated_at": "2020-08-29T17:43:55.102000Z",
"created_at": "2020-08-29T17:43:55.102000Z"
}
] The only problem I have encounter while trying to reproduce the bug was by forgot to set {
"status": "failed",
"updateId": 3,
"type": {
"name": "DocumentsAddition",
"number": 1
},
"error": "serializer error; Primary key is missing.",
"duration": 9.817e-6,
"enqueuedAt": "2020-08-29T17:21:00.098580201Z",
"processedAt": "2020-08-29T17:21:00.100495474Z"
} So, to be honest I don't understand why you don't get a string back on |
@shokme I don’t know. I will resume my work with search in a few days and I will let you know if I find something new. |
It is planned in the MeiliSearch core-engine! 🙂 |
I'm using Laravel 7, MS 0.13
I'm trying to index my model using:
php artisan scout:import "App\Models\Product"
Then I do (local_product is my index):
curl -X GET 'http://localhost:7700/indexes/local_product/documents'
And I get
[]
If I index in Algolia, my documents are ok there.
Also if I index movies doing:
curl -X POST 'http://127.0.0.1:7700/indexes/movies/documents' --data @movies.json
The movies are also indexed.
The text was updated successfully, but these errors were encountered: