# Api php elasticsearch

**URL:** <https://discuss.elastic.co/t/api-php-elasticsearch/136499>\
**Category:** Elasticsearch\
**Created:** [June 19, 2018, 1:26pm UTC](https://discuss.elastic.co/t/api-php-elasticsearch/136499 "2018-06-19T13:26:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jouad\_Mohammed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jouad_mohammed/32/29208_2.png) [@Jouad\_Mohammed](https://discuss.elastic.co/u/Jouad_Mohammed)\
**Post date:** [June 19, 2018, 1:26pm UTC](https://discuss.elastic.co/t/api-php-elasticsearch/136499/1 "2018-06-19T13:26:01Z")

</div>

HI

After migrating my scripts from Es 2.4 to 6.2.1, i removed multi types as specified in the documentation;

I had before 5 types, and now in my script php, how i can search by dropdown list (per types) ??????  
I struggled several days...

this is my code:

//$this-\>client = Elasticsearch\ClientBuilder::create()-\>build();  
$clientBuilder = ClientBuilder::create(); // Instantiate a new ClientBuilder  
$clientBuilder-\>setHosts($hosts); // Set the hosts  
$client = $clientBuilder-\>build();  
$this-\>index = $index;  
$this-\>type = $type;  
$this-\>fuzzy = $fuzziness;

```
    } catch (Exception $e) {

        echo 'Exception received : ', $e->getMessage(), "\n";
	}

}

function search($query) {

	$params = [
	    'index' => $this->index,
	    'type' => $this->type,
	    'size' => 10000 ];

	$params['body']['query']['multi_match']['query'] = $query;
	$params['body']['query']['multi_match']['fields'] = ['_all'];
	$params['body']['query']['multi_match']['fuzziness'] = $this->fuzzy;
	$params['body']['query']['multi_match']['analyzer'] = "standard";
	$result = $this->client->search($params);
	$hit = $result['hits']['hits'];
	
	return $hit;
}

function getTypes() {

	$params['index'] = $this->index;

```

return $this-\>client-\>indices()-\>getMapping();  
//return $this-\>client-\>indices()-\>getMapping($params);  
}

```
function getIndexes() {

	return $this->client->indices()->getMapping();
}

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/c/8cc197adf126a0c0c5845cdc85eccfa45ebee92a.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 17, 2018, 1:26pm UTC](https://discuss.elastic.co/t/api-php-elasticsearch/136499/2 "2018-07-17T13:26:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
