Open MadaniTech opened 5 years ago
Hey @MadaniTech, what issues are caused in your side about having the model path on the objectID?
Thanks for the response @nunomaduro. Is this right to show the path on response while fetching the results from search query? I am writing my logics which also impact on directory path and on the fly I am showing this path as objectID in response.
Yeah - at the moment, moving the model from directory will force you to reimport all records. Maybe we can improve this in the future.
Can I modify it for the time for my project? In case please help me out. Thanks @nunomaduro.
I would also like to override the objectID because saving the entire model path makes no sense if I'm searching from the javascript frontend. I would like the objectIDs to be customised so they can just be Article::1
or Company::5
instead of App\Models\Company::5
.
Laravel has a class_basename
function to get the model name but there's is no method to customize the objectID and I can't override it in the toSearchableArray
method either.
public function toSearchableArray()
{
return [
'objectID' => class_basename($this) . '::' . $this->id,
'name' => $this->name,
'description' => $this-> description,
];
}
+1
Scout Extended is wonderful with its latest features to use Algolia Search API in laravel. But It has a bad approach to save value of Model path with ScoutKey.
On encryption it is using following in ObjectIdEncrypter:
`public static function encrypt($searchable, int $part = null): string { $scoutKey = method_exists($searchable, 'getScoutKey') ? $searchable->getScoutKey() : $searchable->getKey(); $meta = [get_class($searchable->getModel()), $scoutKey];
if ($part !== null) { $meta[] = $part; } return implode(self::$separator, $meta); }`
Because of this ObjectID is importing like this:
objectID: {ModelPath}::ScoutKey
on importing and searching results also show a string including Model Path. Any body can help in this matter.