Answer the question
In order to leave comments, you need to log in
How to check for the existence of id in elasticsearch?
There is a function for deleting a record from the database and deleting a record from ElasticSearch by id from the database. I encountered
a problem that there is a record in the database, but there is no record in ElasticSearch, and when trying to delete a non-existent record from ES, an error occurs
How to check for the existence of id in ES?
Tried like this -
$items = $elastic->search([
'index' => 'baza',
'type' => 'prod',
'body' => [
"query" => [
"ids" => [
"values" => [$id]
]
]
]
]);
Elasticsearch\Common\Exceptions\Missing404Exception
{"_index":"baza","_type":"prod","_id":"1569568","_version":1,"result":"not_found","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":500770,"_primary_term":1}
Answer the question
In order to leave comments, you need to log in
After reading the documentation, I found a suitable way for me
GET my-index-000001/_search
{
"query": {
"terms": {
"_id": [ "1", "2" ]
}
}
}
$items = $elastic->search([
'index' => 'baza',
'body' => [
"query" => [
"terms" => [
"_id" => [ $id ]
]
]
]
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question