Issue with algolia and laravel

Hi there, I’m using your amazing product. If I create a record on my local DB, the record is pretty Indexed on Algolia, but if I create a record on my remote DB there is a problem:
The record is present in Algolia index, but if I try to search that item I had an error.
Algolia\ScoutExtended\Exceptions\ShouldReimportSearchableException

ObjectID seems invalid. You may need to re-import your data using the scout-reimport Artisan command.

if I reimport all things works.
What i need to check? I use Laravel 7.13

Hi @vito, could you provide more information about how your records are getting indexed from your local DB? Could you provide the objectID of one of those records? This is where the error is coming from. It is checking that the objectID is an array of at least 2 elements. Does that help you track down the issue with the objectID?

Hi @cindy.cullen thanks for replay. I just follow the instruction on Laravel website. I add the trait on my model
use Laravel\Scout\Searchable;

class Books extends Model
{
use Searchable;

Hi @vito, Are you using Laravel Scout extended? Can you provide the versions of Laravel, Scout and Scout Extended? Could you include a copy of the request coming from Laravel? Also provide a stack trace if available.

I look forward to your reply!

Thanks @cindy.cullen, yes I use scout exetended:
“algolia/algoliasearch-client-php”: “^2.6”,
“laravel/scout”: “^8.0”,

Controller:
use Illuminate\Http\Request;
use App\Books;
use App\Search\Arianna;

public function search(Request $request){

    $books = Books::search($request->get('query'))->paginate(20);

namespace App\Search;

use Algolia\ScoutExtended\Searchable\Aggregator;

class Arianna extends Aggregator
{
/**
* The names of the models that should be aggregated.
*
* @var string
*/
protected $models = [
\App\Books::class,
\App\Author::class,
];
}

Hi @vito, could it be that the local and remote code bases have different objectID formats? Is there a difference in the codebase? If you are indexing with one environment and searching with another, you may be running into issues if the codebase is different and expects the objectIDs to be in different formats or if the objectID may not be found in the other database?

Hello @cindy.cullen, how can I check the object ID? Anyway I don’t think that there is a different object ID.

Hey @vito,

You are having that issue because the index at Algolia contains records that weren’t indexed using Laravel Scout Extended. Therefore, you need to import them to Algolia once again using Laravel Scout Extended’s command scout:reimport for example.

Normally, the objectID of your records at Algolia need to look to something like this: “App\YourModel::1”.

Let me know if you have any other question,
Nuno.

Not relevant, but you can check the objectID of your records on your Algolia Dashboard > index name.

Thanks,
Nuno

good morning @nuno.maduro, thanks for you answer. "Algolia contains records that weren’t indexed using Laravel Scout Extended. " why if I add a new record on my local ambient all works? Remote environment and local environment are the same.

Is the remote environment and local environment hitting the same index? If not, check if the remote environment contains records in Algolia indexed using Laravel Scout Extended.

thanks Nuno, using laravel scout extended I fixed all issue