|
|
@@ -431,9 +431,9 @@ class OpenSearchService
|
|
|
* @type string $category 按分类过滤
|
|
|
* @type array $tags 按标签过滤(terms)
|
|
|
* @type array $pageRefs 按页码引用过滤(terms)
|
|
|
- * @type string $relatedId 按关联 ID 过滤
|
|
|
+ * @type string|array $relatedId 按关联 ID 过滤(数组时命中任一)
|
|
|
* @type string $author 按作者过滤
|
|
|
- * @type string $channel 按频道过滤
|
|
|
+ * @type string $channel 按频道过滤(channel uuid)
|
|
|
* @type array $highlight_pre_tags 高亮前置标签,默认 ['<mark>']
|
|
|
* @type array $highlight_post_tags 高亮后置标签,默认 ['</mark>']
|
|
|
* }
|
|
|
@@ -497,15 +497,19 @@ class OpenSearchService
|
|
|
}
|
|
|
|
|
|
if (! empty($params['relatedId'])) {
|
|
|
- $filters[] = ['term' => ['related_id' => $params['relatedId']]];
|
|
|
+ $filters[] = is_array($params['relatedId'])
|
|
|
+ ? ['terms' => ['related_id' => array_values($params['relatedId'])]]
|
|
|
+ : ['term' => ['related_id' => $params['relatedId']]];
|
|
|
}
|
|
|
|
|
|
if (! empty($params['author'])) {
|
|
|
$filters[] = ['match' => ['metadata.author' => $params['author']]];
|
|
|
}
|
|
|
|
|
|
+ // metadata.channel 在映射里是 text(标准分词器会把 uuid 按连字符拆开),
|
|
|
+ // term 拿整个 uuid 去比永远对不上,只能按短语匹配
|
|
|
if (! empty($params['channel'])) {
|
|
|
- $filters[] = ['term' => ['metadata.channel' => $params['channel']]];
|
|
|
+ $filters[] = ['match_phrase' => ['metadata.channel' => $params['channel']]];
|
|
|
}
|
|
|
|
|
|
// ---------- 查询部分 ----------
|