ruflin/Elastica

Type: Error Message: Call to undefined method Elastica\Index::getType()

laTruffe79 opened this issue · 4 comments

Hello I read that ES 7.x is not handling types anymore so what is the way to with that ? I must update my code, have you an example please ?
Thanks.

You likely have to update your code. But first it is important to understand what exactly changes: https://www.elastic.co/guide/en/elasticsearch/reference/7.x/removal-of-types.html For code examples, IndexTests and others are always a good place: https://github.com/ruflin/Elastica/blob/master/tests/IndexTest.php

OK, the joy of updates... ^_^

Ok if it could help someone without spending time here are the changes

//There is no need to use a type
//$type = $index->getType($this->esType);

// path before :
//$path = $index->getName() . '/' . $type->getName() . '/_search';

// path after : 
$path = $this->esType . '/_doc/_search';

$response = $elasticaClient->request($path, Request::GET, $query);

@laTruffe79 IMHO you should use the $client->getIndex($name)->search($query) construction.
It makes sure that the POST is used when running a search too ;-)

Closing this issue