How to get existing index object, if index exists in php elastica

Hi,

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.

I think its a very trivial task, should have easily found a fix, but am
unable to fix this. Hope you guys will be kind enough to help me out.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/da2f6e7a-5f5b-4cda-b602-6e5ea362d480%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

My bad. It was so easy: $index = $client->getIndex($name); Had some problem
in my code itself.
Thanks anyways.

On Sunday, March 15, 2015 at 3:30:01 PM UTC+5:30, nitin birdi wrote:

Hi,

I am new to Elasticsearch. 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.

I think its a very trivial task, should have easily found a fix, but am
unable to fix this. Hope you guys will be kind enough to help me out.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2849a69e-f289-42e1-8e3b-4ac4fd1f817f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.