I have a Laravel model called Car, with a JSON attribute named arabic_data. This attribute stores the same car model but with values in Arabic. Here’s an example of how I create and populate the model:
$car = new Car();
$car->fill([
'make_id' => 1,
'model_id' => 1,
'year' => 2024,
'body_type_id' => 1,
'km' => 50000,
// other attributes...
]);
$arabicCar = $car->clone();
$arabicCar->fill([
'body_type' => self::BODY_TYPE_ARABIC_MAPPER[$valuationData['carNameBody']] // other Arabic attributes...
]);
$car->arabic_data = $arabicCar->toJson();
$car->save();
return $car;
When synchronizing this model to Algolia, it gets saved with one index. The Arabic data is treated as another attribute, and Algolia creates indexes based on the model ID. Thus, I can’t create a new index for the Arabic data separately because both the original and Arabic versions share the same ID.
My question:
Is there a way to configure Algolia to create a separate index specifically for the Arabic data stored in the JSON attribute Arabic_data? If so, how can I implement this in my Laravel application?