Como É Que o Multy consegue uma amostra da Elasticsearch php?
apreender o cliente Elasticsearch em php. Como posso encontrar um monte de documentos no ES, para id, é igual a "onde id em (1,2,3,4,9)" em SQL? Para mono get eu faço assim
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'
];
$ response = $ client-> get ($ params);
Como obter alguns registos?
Eu tentei, mas não funciona.
$ params = [[
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'
]
[
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id2'
]];
$ response = $ client-> mget ($ params);
e assim
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => array ('my_id', 'my_id2')
];
$ response = $ client-> mget ($ params);
a API é que o PHP só tem https: https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_getting_documents.html
É mais ou menos isso, só o CURL pede https.: https://www.elastic.co/guide/en/elasticsearch/reference/1.4/docs-multi-get.html Quem trabalhou com a ES, ajude-me, por favor!) 2
2 answers
Você simplesmente precisa de usar o ids
filtro, assim:
$params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => [
'query' => [
'filtered' => [
'filter' => [
'ids' => [
'values' => ['my_id', 'my_id2']
]
]
]
]
]
];
$results = $client->search($params);
Actualizar
Se quer mesmo usar mget
, então deve fazê-lo assim:
$ params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => ['ids' => ['my_id', 'my_id2']]
];
$ response = $ client-> mget ($ params);
3
Author: Val, 2018-10-02 15:00:46
Adicionar abaixo da linha durante inserir
"refresh"=> true
-1
Author: user6360752, 2016-11-24 14:59:38