zingimmick / laravel-scout-opensearch

Laravel Scout custom engine for OpenSearch
MIT License
19 stars 6 forks source link

Unable to search via model after indexing records: illegal_argument_exception #62

Closed latheesan-k closed 1 year ago

latheesan-k commented 1 year ago

I have some records in my index named assets_index, when ever I try to search them via a the Asset model like this:

$result = \App\Models\Asset::search('some value here')->get();
dd($result->toArray());

I am getting the following error:

Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [id] in order to load field data by uninverting the inverted index. Note that this can use significant memory.

Here's the full error: https://pastebin.com/raw/VTsK9eBd

Any idea what could be causing this?

Apologises in advance if this is not related to this driver for scout, i am new to both Laravel Scout and OpenSearch, just trying to get a basic index + search going.

I wrote a detailed question on StackOverflow here: https://stackoverflow.com/questions/76478329/laravel-scout-with-aws-opensearch-illegal-argument-exception-when-searching-on-m

zingimmick commented 1 year ago

There are two problems here:

  1. This project has an issue when use UUIDs(or string type value) as primary keys.
  2. Using a combined field as the scout key is the wrong way to go, because Laravel Scout retrieves the requested models from an array of object IDs.
    public function getScoutKey(): string
    {
        return $this->policy_id . $this->asset_id;
    }