Skip to content

Commit 223012c

Browse files
committed
1 parent e9bf0b0 commit 223012c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Client.php

+8
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ public function updateIndexSettings(string $target, array $body = null): Promise
225225
return $this->doJsonRequest($method, $uri, $body);
226226
}
227227

228+
public function updateMappings(string $target, array $body = null): Promise
229+
{
230+
$method = 'PUT';
231+
$uri = implode('/', [$this->baseUri, urlencode($target), '_mappings']);
232+
233+
return $this->doJsonRequest($method, $uri, $body);
234+
}
235+
228236
private function createJsonRequest(string $method, string $uri, string $body = null): Request
229237
{
230238
$request = new Request($uri, $method);

tests/Integration/ClientTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,18 @@ public function testUpdateIndexSettings(): void
370370
$response = Promise\wait($this->client->getIndex(self::TEST_INDEX));
371371
$this->assertEquals(2000, $response[self::TEST_INDEX]['settings']['index']['mapping']['total_fields']['limit']);
372372
}
373+
374+
public function testUpdateMappings(): void
375+
{
376+
Promise\wait($this->client->createIndex(self::TEST_INDEX));
377+
378+
$response = Promise\wait(
379+
$this->client->updateMappings(self::TEST_INDEX, ['properties' => ['testField' => ['type' => 'text']]])
380+
);
381+
382+
$this->assertIsArray($response);
383+
$this->assertTrue($response['acknowledged']);
384+
$response = Promise\wait($this->client->getIndex(self::TEST_INDEX));
385+
$this->assertEquals('text', $response[self::TEST_INDEX]['mappings']['properties']['testField']['type']);
386+
}
373387
}

0 commit comments

Comments
 (0)