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

Nested query fails. Issue with Mapping? #160

Open
thitami opened this issue Jun 4, 2018 · 0 comments
Open

Nested query fails. Issue with Mapping? #160

thitami opened this issue Jun 4, 2018 · 0 comments

Comments

@thitami
Copy link

thitami commented Jun 4, 2018

I am quite new to ES and am using the sleimanx2/plastic package to integrate it with my app.

I have got the following models:

Record and Contributor

In Record model:

/**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function contributors()
    {
        return $this->belongsToMany(Contributor::class, 'contributor_record', 'record_id', 'contributor_id');
    }

In Contributor model I have got the following relationship:

 /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function records()
    {
        return $this->belongsToMany(Record::class, 'contributor_record', 'contributor_id', 'record_id');
    }

Issue is that when I am trying to search against the contributor's name property I am getting the exception:

{"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query: {\n \"nested\" : {\n \"query\" : {\n \"match\" : {\n \"contributors.name\" : {\n \"query\" : \" * Int * \",\n \"operator\" : \"OR\",\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"fuzzy_transpositions\" : true,\n \"lenient\" : false,\n \"zero_terms_query\" : \"NONE\",\n 

The code I am using to query the contributor's name is:

return $this->record->search()->nested('contributors', function (SearchBuilder $builder) use ($searchTerm) {
            $builder->match('contributors.name', ' * '.$searchTerm.' * ');
        })->size(500)->get()->hits();

Would you consider this a Mapping issue?

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

No branches or pull requests

1 participant