我有一个两种不同类型的索引:
[hits] => Array
(
[total] => 408863
[max_score] => 1
[hits] => Array
(
[0] => Array
(
[_index] => myindex
[_type] => merch
[_id] => 379919
[_score] => 1
[_source] => Array
(
[id] => 379919
[field1] => Lorem ipsum
[field2] => ERKDK56
[field3] => 1256
...
[hits] => Array
(
[total] => 4172386
[max_score] => 1
[hits] => Array
(
[0] => Array
(
[_index] => myindex
[_type] => merchSeller
[_id] => 2599218
[_score] => 1
[_source] => Array
(
[id] => 2599218
[field4] => 1
[field5] => 1
[merch] => Array
(
[id] => 132539
[field6] => 132539
)
[seller] => Array
(
[id] => 689
[field7] => 1
...
如何创建一个可以同时检查两种类型字段的查询?
我通过在类型字段中添加两种类型来创建查询,希望我可以访问这些字段,但它没有返回好的结果。
$params = [
'index' => 'myindex',
'type' => 'merch,merchSeller',
'body' => [
'query' => [
'bool' => [
'must'=> [
'match' => ['field1' => 'Lorem'] ,
],
'must'=> [
'match' => ['field4' => '23'],
]
]
]]
];
我使用laravel与“ElasticSearch/ElasticSearch”:“~7.1”。
谢谢你
1条答案
按热度按时间hivapdat1#
选择_type等于merc且匹配字段1的记录或_type等于merchSeller且匹配字段4的记录
}
请注意,_type已被取代。