Problems, solutions and everything in between.
Latest entries

Elasticsearch PHP - Create or Update a document if it doesn’t exist

$client = ClientBuilder::create()->build(); $id = 123; $params = []; $params['index'] = self::INDEX; $params['type'] = self::TYPE; $params['id'] = $id; $params['body']["doc"]['data']['body-test'] = 'abc'; $params['body']["doc_as_upsert"] = true; return $client->update($params); The important part I was missing is the "doc_as_upsert" on the body.

Useful Elasticsearch Tips, Tools and commands

Delete all indexes curl -X DELETE 'http://localhost:9200/_all' Get the mapping and the settings GET /index_name/_mapping GET /index_name/_settings Import data VIA curl into Elastic curl -H "Content-Type: application/json" -XPOST "http://localhost:9200/INDEX-PATH/_bulk?pretty" --data-binary @path/to/file/test.json Aggregations GET /index/type/_search { "query": { "match": { "name": "SEARCH_TERM" } }, "size": 0, "aggs": { "quantity_sum": { "sum": { "field": "price" } } } } Multiple Aggregations…