I am new to elastic search. I am using php elastica client and facing a problem: If an index exists, I want to get the object of this existing index and not recreate it. How can this be done?
client = new \Elastica\Client($arrServerConf, $callback);
if ( $client->getIndex($name)->exists() ) {
//do something here to get this existing object -- what to do here???
} else {
// create a new one
$index = $client->getIndex($name);
$index->create(array('index' => array('number_of_shards' => $shards, 'number_of_replicas' => 0)), $delete);
}
$type = $index->getType($typeName);
Or is there some other way of doing this? I need this because, I'll be adding documents in this index and searching among them.
My bad. I could easily do it with the same: $index = $client->getIndex($name);
There was some problem in my code itself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.