Torann / laravel-cloudsearch

Index and search Laravel models on Amazon's CloudSearch
BSD 2-Clause "Simplified" License
22 stars 10 forks source link

search:import abstract method error for getSearchDocument #1

Closed BirdyUK closed 5 years ago

BirdyUK commented 7 years ago

Hey Torann, Just want to say great work you have done with this package, Ive just started to learn cloud search so everything is quite new and looking forward to working with a much more laravel friendly way by using your package. I appreciate the time and effort you have gone to with making this package it is very clean.

I have an issue i face when using search:import. I have tried with and without the Searchable triat being added to the model, The first error i get without the trait is:


php artisan search:index MasterTest 
Model [\App\Api\MasterTest ] does not support searching.

With the searchable trait:

php artisan search:index MasterTest 
PHP Fatal error:  Class App\Api\MasterTest contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (App\Api\MasterTest::getSearchDocument) in /www/app/Api/MasterTest.php on line 8

[Symfony\Component\Debug\Exception\FatalErrorException]                                                                                                               
  Class App\Api\MasterTest contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (App\Api\MasterTest::getSearchDocument)  

I have attempted to add a getSearchDocument method but unsure what the method should return or if it should be present on the model as it does not mention this in the docs?

Any help would be greatly appreciated, Thansk.

Torann commented 6 years ago

It just returns an array.

    /**
     * Get CloudSearch document data for the model.
     *
     * @return array|null
     */
    public function getSearchDocument()
    {
        return [
            'id' => $this->id,
            'locale' => $this->locale,
            'name' => $this->name,
            'tags' => $this->getAllTagIds(),
        ];
    }
deevus commented 5 years ago

Is this documented somewhere? It's not in the README

Torann commented 5 years ago

@deevus just what's in the readme