Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
latheesan-k opened this issue Jun 15, 2023 · 1 comment · Fixed by #63
Closed

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

latheesan-k opened this issue Jun 15, 2023 · 1 comment · Fixed by #63

Comments

@latheesan-k
Copy link

latheesan-k commented Jun 15, 2023

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
Copy link
Owner

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;
    }

zingimmick added a commit that referenced this issue Jun 15, 2023
* Reproduce issue #62

* Rector Rectify

* Skip ScoutHasUuidsTest when class HasUuids not exists

* Skip ScoutHasUuidsTest when class HasUuids not exists

* Rector Rectify

* Remove default sort option

* Rector Rectify

* Remove default sort option

* Rector Rectify

* Fix phpdoc

---------

Co-authored-by: zingimmick <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants