我是ES的新手,我正在使用sleimanx2/plastic
包将其与我的应用集成。
我有以下型号:
Record
和Contributor
在Record
模型中:
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function contributors()
{
return $this->belongsToMany(Contributor::class, 'contributor_record', 'record_id', 'contributor_id');
}
在Contributor
模型中,我有以下关系:
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function records()
{
return $this->belongsToMany(Record::class, 'contributor_record', 'contributor_id', 'record_id');
}
问题是,当我尝试搜索贡献者的名称属性时,我得到了例外:
{"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
我用来查询贡献者姓名的代码是:
return $this->record->search()->nested('contributors', function (SearchBuilder $builder) use ($searchTerm) {
$builder->match('contributors.name', ' * '.$searchTerm.' * ');
})->size(500)->get()->hits();
有什么想法吗?