11summary : Update index analysis
2- method_request : POST /my-index-000001/_close
3- description : To add an analyzer, you must close the index, define the analyzer, then reopen the index.
2+ method_request : PUT /my-index-000001/_settings
3+ description :
4+ To add an analyzer, you must close the index (`POST /my-index-000001/_close`), define the analyzer, then reopen the
5+ index (`POST /my-index-000001/_open`).
46# type: request
5- value : " {
6-
7- \ \" analysis\" : {
8-
9- \ \" analyzer\" :{
10-
11- \ \" content\" :{
12-
13- \ \" type\" :\" custom\" ,
14-
15- \ \" tokenizer\" :\" whitespace\"
16-
17- \ }
18-
19- \ }
20-
21- \ }
22-
7+ value : |-
8+ {
9+ "analysis": {
10+ "analyzer": {
11+ "content": {
12+ "type": "custom",
13+ "tokenizer": "whitespace"
14+ }
15+ }
16+ }
2317 }
24-
25-
26- POST /my-index-000001/_open"
2718alternatives :
2819 - language : Python
2920 code : |-
30- resp = client.indices.close(
31- index="my-index-000001",
32- )
33-
34- resp1 = client.indices.open(
21+ resp = client.indices.put_settings(
3522 index="my-index-000001",
23+ settings={
24+ "analysis": {
25+ "analyzer": {
26+ "content": {
27+ "type": "custom",
28+ "tokenizer": "whitespace"
29+ }
30+ }
31+ }
32+ },
3633 )
3734 - language : JavaScript
3835 code : |-
39- const response = await client.indices.close({
40- index: "my-index-000001",
41- });
42-
43- const response1 = await client.indices.open({
36+ const response = await client.indices.putSettings({
4437 index: "my-index-000001",
38+ settings: {
39+ analysis: {
40+ analyzer: {
41+ content: {
42+ type: "custom",
43+ tokenizer: "whitespace",
44+ },
45+ },
46+ },
47+ },
4548 });
4649 - language : Ruby
4750 code : |-
48- response = client.indices.close (
51+ response = client.indices.put_settings (
4952 index: "my-index-000001",
5053 body: {
5154 "analysis": {
@@ -58,13 +61,9 @@ alternatives:
5861 }
5962 }
6063 )
61-
62- response1 = client.indices.open(
63- index: "my-index-000001"
64- )
6564 - language : PHP
6665 code : |-
67- $resp = $client->indices()->close ([
66+ $resp = $client->indices()->putSettings ([
6867 "index" => "my-index-000001",
6968 "body" => [
7069 "analysis" => [
@@ -77,13 +76,8 @@ alternatives:
7776 ],
7877 ],
7978 ]);
80-
81- $resp1 = $client->indices()->open([
82- "index" => "my-index-000001",
83- ]);
8479 - language : curl
85- code : >-
86- curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d
87- '{"analysis":{"analyzer":{"content":{"type":"custom","tokenizer":"whitespace"}}}}' "$ELASTICSEARCH_URL/my-index-000001/_close"
88-
89- curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/my-index-000001/_open"
80+ code :
81+ ' curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d
82+ '' {"analysis":{"analyzer":{"content":{"type":"custom","tokenizer":"whitespace"}}}}''
83+ "$ELASTICSEARCH_URL/my-index-000001/_settings"'
0 commit comments