Giter VIP home page Giter VIP logo

Comments (11)

karakhanyans avatar karakhanyans commented on June 6, 2024 2

@1stevengrant now the latest release is v5.2.7, you can upgrade to it.

from laravel-scout-typesense-driver.

karakhanyans avatar karakhanyans commented on June 6, 2024 1

Please update the driver to the latest version, which already supports $document as a both string and array.

from laravel-scout-typesense-driver.

Muffinman avatar Muffinman commented on June 6, 2024 1

Yes can confirm this worked fine for me on v5.2.7. Thanks for your help!

from laravel-scout-typesense-driver.

mhmiton avatar mhmiton commented on June 6, 2024 1

@karakhanyans Thanks. It's working now. Also, it will be better, if the latest release is v5.2.7. Now the latest release is v5.2.2.

image

from laravel-scout-typesense-driver.

Muffinman avatar Muffinman commented on June 6, 2024

I'm getting this too, and even after fixing that it seems like there's several other issues in the code where it's expecting strings but actually returning arrays.

Is this driver stable / tested properly?

from laravel-scout-typesense-driver.

karakhanyans avatar karakhanyans commented on June 6, 2024

Good morning @mhmiton @Muffinman

We've checked the code, and the latest version of the driver supports both string and array.

Could you please send us the version of your Laravel project, the PHP version that you are using and laravel-scout-typesense-driver version that you are using?

from laravel-scout-typesense-driver.

Muffinman avatar Muffinman commented on June 6, 2024

After some debugging, what I think is happening is that TypeSense is complaining about the data being ingested, and returning a different error JSON structure to that which the code is expecting.

Will post more info when I have it.

Typesense version: 0.25.0.rc64
typesense/laravel-scout-typesense-driver: "5.2.6"
  Environment ...........................................
  Application Name ................................ *****
  Laravel Version ............................... 10.18.0
  PHP Version ..................................... 8.2.7
  Composer Version ................................ 2.5.8
  Environment ..................................... local
  Debug Mode .................................... ENABLED
  URL ............................................... ***
  Maintenance Mode .................................. OFF

  Cache .................................................
  Config ..................................... NOT CACHED
  Events ..................................... NOT CACHED
  Routes ..................................... NOT CACHED
  Views ...................................... NOT CACHED

  Drivers ...............................................
  Broadcasting ...................................... log
  Cache ........................................... redis
  Database ........................................ mysql
  Logs ................................... stack / single
  Mail ............................................. smtp
  Queue ........................................... redis
  Scout ....................................... typesense
  Session .......................................... file

Full error stack trace:

$ php artisan scout:import \\App\\Models\\Product


   TypeError

  Typesense\Documents::import(): Argument #1 ($documents) must be of type string, array given, called in /Users/matt/Sites/*******/vendor/typesense/laravel-scout-typesense-driver/src/Typesense.php on line 190

  at vendor/typesense/typesense-php/src/Documents.php:97
     93▕      * @return string
     94▕      * @throws TypesenseClientError
     95▕      * @throws GuzzleException
     96▕      */
  ➜  97▕     public function import(string $documents): string
     98▕     {
     99▕         return $this->apiCall->post($this->endPointPath('import'), $documents, false);
    100▕     }
    101▕

  1   vendor/typesense/laravel-scout-typesense-driver/src/Typesense.php:190
      Typesense\Documents::import(["upsert"])

  2   vendor/typesense/laravel-scout-typesense-driver/src/Engines/TypesenseEngine.php:172
      Typesense\LaravelTypesense\Typesense::importDocuments(Object(Typesense\Collection))

  3   vendor/laravel/scout/src/Searchable.php:63
      Typesense\LaravelTypesense\Engines\TypesenseEngine::update(Object(Illuminate\Database\Eloquent\Collection))

  4   vendor/laravel/scout/src/Searchable.php:42
      App\Models\Category::queueMakeSearchable(Object(Illuminate\Database\Eloquent\Collection))

  5   vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:123
      Illuminate\Database\Eloquent\Collection::Laravel\Scout\{closure}()

  6   vendor/laravel/scout/src/SearchableScope.php:38
      Illuminate\Support\Collection::__call("searchable", [])

  7   vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:141
      Laravel\Scout\SearchableScope::Laravel\Scout\{closure}(Object(Illuminate\Database\Eloquent\Collection))

  8   vendor/laravel/scout/src/SearchableScope.php:37
      Illuminate\Database\Eloquent\Builder::chunkById(Object(Closure), "products.id", "id")

  9   vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1907
      Laravel\Scout\SearchableScope::Laravel\Scout\{closure}(Object(Illuminate\Database\Eloquent\Builder))

  10  vendor/laravel/scout/src/Searchable.php:151
      Illuminate\Database\Eloquent\Builder::__call("searchable")

  11  vendor/laravel/scout/src/Console/ImportCommand.php:45
      App\Models\Product::makeAllSearchable()

  12  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      Laravel\Scout\Console\ImportCommand::handle(Object(Illuminate\Events\Dispatcher))

  13  vendor/laravel/framework/src/Illuminate/Container/Util.php:41
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  14  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
      Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

  15  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
      Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))

  16  vendor/laravel/framework/src/Illuminate/Container/Container.php:662
      Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])

  17  vendor/laravel/framework/src/Illuminate/Console/Command.php:211
      Illuminate\Container\Container::call()

  18  vendor/symfony/console/Command/Command.php:326
      Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  19  vendor/laravel/framework/src/Illuminate/Console/Command.php:180
      Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  20  vendor/symfony/console/Application.php:1081
      Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  21  vendor/symfony/console/Application.php:320
      Symfony\Component\Console\Application::doRunCommand(Object(Laravel\Scout\Console\ImportCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  22  vendor/symfony/console/Application.php:174
      Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  23  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:201
      Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  24  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

from laravel-scout-typesense-driver.

Muffinman avatar Muffinman commented on June 6, 2024

I only installed this yesterday! Not sure why it pulled down 5.2.6 instead of 5.2.7.

Will update and report back.

from laravel-scout-typesense-driver.

karakhanyans avatar karakhanyans commented on June 6, 2024

Glad to hear that it solved @Muffinman

@mhmiton could you do upgrade on your side too?

from laravel-scout-typesense-driver.

1stevengrant avatar 1stevengrant commented on June 6, 2024

yeah, I just installed this morning and I got 5.2.6 and not 5.2.7

from laravel-scout-typesense-driver.

Smokietr avatar Smokietr commented on June 6, 2024

I tried all the versions you suggested. error persists. Column type is json. Laravel collection returned array.

5.2.6, 5.2.7, 5.2,8

Typsense Version : 0.26.0.rc47

class Book extends Model
{
    use HasFactory, Searchable;

    protected $fillable = [
        'identifiers', 'reading_statuses', 'rating', 'reviews', 'quotes', 'clicks'
    ];

    protected $casts = [
        'identifiers' => 'json',
        'reading_statuses' => 'json',
    ];

    public function toSearchableArray(): array
    {

        return array_merge($this->toArray(),[
            'id' => (string)$this->id,
            'identifiers' => (object)$this->identifiers,
        ]);
    }

    public function getCollectionSchema(): array
    {
        return [
            'enable_nested_fields' => true,
            'name' => $this->searchableAs(),
            'fields' => [
                [
                    'name' => 'id',
                    'type' => 'string',
                ],
                [
                    'name' => 'identifiers',
                    'type' => 'object[]',
                ],
                [
                    'name' => 'created_at',
                    'type' => 'int64',
                ],
            ],
            'default_sorting_field' => 'created_at',
        ];
    }

    public function typesenseQueryBy(): array {
        return [
            'identifiers.isbn-13',
        ];
    }

    public function bookTranslates(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
    {
        return $this->hasManyThrough(BookTranslate::class, BookTranslatePivot::class, 'book_id', 'id', 'id', 'translate_id');
    }
}

Error importing document: Field **identifiers** has an incorrect type.

from laravel-scout-typesense-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.