我有两个索引:X和Y我需要在X索引上搜索,并在Y.上运行建议
Y 的映射
$config['params']['suggestion']['body']['mappings']['suggester'] = [
'properties' =>
[
'search_id' => [
'type' => 'string',
'index' => 'not_analyzed'
],
'autosuggest_query' => [
'type' => 'completion',
"analyzer" => "my_suggester_analyzer",
"search_analyzer" => "my_suggester_analyzer",
"preserve_separators" => "false",
"preserve_position_increments" => "false",
"payloads" => true
],
'product_count' => [
'type' => 'integer',
],
'search_count' => [
'type' => 'integer',
]
]
我在X中搜索产品,获得聚合数据,并在同一个查询中运行suggester从索引Y(自动建议查询)中搜索以前的查询
查询:
GET _search
{
"query": {
"filtered": {
"query": {
"bool": {
"should": {
"multi_match": {
"type": "phrase",
"query": "dinning table cover",
"fields": [
"q1^20",
"q2^10"
],
"slop": "3"
}
}
}
}
}
},
"size": 0,
"aggs": {
"category_L1": {
"terms": {
"field": "product_root_category_slug",
"size": 2,
"min_doc_count": 1
},
"aggs": {
"category_L2": {
"terms": {
"field": "product_main_category_slug",
"size": 1,
"min_doc_count": 1
},
"aggs": {
"category_L3": {
"terms": {
"field": "category_slug",
"size": 1,
"min_doc_count": 1
},
"aggs": {
"cat_name": {
"terms": {
"field": "category.raw"
}
}
}
}
}
}
}
}
},
"suggest": {
"suggester_a": {
"text": "dinning table cover",
"completion": {
"field": "autosuggest_query",
"fuzzy": {
"fuzziness": 0
}
}
}
}
我得到了异常
["failures"]=>
array(1) {
[0]=>
array(4) {
["index"]=>
string(18) "X"
["shard"]=>
int(0)
["status"]=>
int(500)
["reason"]=>
string(83) "ElasticsearchException[Field [autosuggest_query] is not a completion suggest field]"
}
}
有人吗?感谢
我不知道你的情况是否有效(在X上运行查询,在Y上运行suggester),但如果你仔细查看异常跟踪,你可以看到它在X
索引上失败:
...
["index"]=>
string(18) "X"
["shard"]=>
...
文件中写道:
建议在查询阶段中收集
所以我想它会触发那个异常,因为它在X
索引上运行查询,但在上面找不到那个字段。