Multy 如何获取 Elasticsearch php 的样本?
How do Multy get a sample of Elasticsearch php?
在 php 中利用 Elasticsearch 客户端。
怎么在ES中找到很多文档,对于id,在SQL中等于"WHERE id IN (1,2,3,4,9)"?
对于单声道,我这样做
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'
];
$ response = $ client-> get ($ params);
如何获取一些记录?
我试过了,还是不行
$ params = [[
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'
]
[
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id2'
]];
$ response = $ client-> mget ($ params);
等等
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => array ('my_id', 'my_id2')
];
$ response = $ client-> mget ($ params);
API是PHP只有https:https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_getting_documents.html
就是这样,只有CURL请求https:https://www.elastic.co/guide/en/elasticsearch/reference/1.4/docs-multi-get.html
谁用过ES,请帮忙!)
您只需使用 ids
过滤器,如下所示:
$params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => [
'query' => [
'filtered' => [
'filter' => [
'ids' => [
'values' => ['my_id', 'my_id2']
]
]
]
]
]
];
$results = $client->search($params);
更新
如果你绝对想使用mget
,那么你应该这样做:
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => ['ids' => ['my_id', 'my_id2']]
];
$ response = $ client-> mget ($ params);
只需在插入过程中添加下面一行
"refresh"=> true
阅读源代码\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Client.php和mget函数。你应该这样做:
$params = [
'index' => 'index',
'type' => 'type',
'body' => array('ids' => array('id1', 'id2'))
];
$response = $ client-> mget ($ params);
foreach ($response ['docs'] as $doc)
{
$source = $doc['_source'];
}
在 php 中利用 Elasticsearch 客户端。 怎么在ES中找到很多文档,对于id,在SQL中等于"WHERE id IN (1,2,3,4,9)"? 对于单声道,我这样做
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'
];
$ response = $ client-> get ($ params);
如何获取一些记录? 我试过了,还是不行
$ params = [[
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'
]
[
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id2'
]];
$ response = $ client-> mget ($ params);
等等
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => array ('my_id', 'my_id2')
];
$ response = $ client-> mget ($ params);
API是PHP只有https:https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_getting_documents.html
就是这样,只有CURL请求https:https://www.elastic.co/guide/en/elasticsearch/reference/1.4/docs-multi-get.html
谁用过ES,请帮忙!)
您只需使用 ids
过滤器,如下所示:
$params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => [
'query' => [
'filtered' => [
'filter' => [
'ids' => [
'values' => ['my_id', 'my_id2']
]
]
]
]
]
];
$results = $client->search($params);
更新
如果你绝对想使用mget
,那么你应该这样做:
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => ['ids' => ['my_id', 'my_id2']]
];
$ response = $ client-> mget ($ params);
只需在插入过程中添加下面一行
"refresh"=> true
阅读源代码\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Client.php和mget函数。你应该这样做:
$params = [
'index' => 'index',
'type' => 'type',
'body' => array('ids' => array('id1', 'id2'))
];
$response = $ client-> mget ($ params);
foreach ($response ['docs'] as $doc)
{
$source = $doc['_source'];
}