# Watcher / Deprecation: \[types removal\] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/\_doc/{id}, /{index}/\_doc, or /{index}/\_create/{id})

**URL:** https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [January 28, 2020, 9:54am UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800 "2020-01-28T09:54:42Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![pierrejutard](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pierrejutard](https://discuss.elastic.co/u/pierrejutard)
#### Post date: [January 28, 2020, 9:54am UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/1 "2020-01-28T09:54:42Z")

</div>

Hello,

When trying to insert a watcher in ElasticSearch:

PUT /watcher/watch/pricealert  
{  
"watch":  
{  
"trigger": {  
"schedule": {  
"interval": "1m"  
}  
},  
"input": {  
"chain": {  
"inputs": [  
{  
"first": {  
"search": {  
"request": {  
"indices": [  
"price-request-2020.01.28"  
],  
"body": {  
"query": {  
"match\_all": {}  
}  
}  
}  
}  
}  
},  
{  
"second": {  
"search": {  
"request": {  
"indices": [  
"mktdata-2020.01.28"  
],  
"body": {  
"query": {  
"match\_all": {}  
}  
}  
}  
}  
}  
}  
]  
}  
},  
"condition": {  
"script": {  
"source": "return ctx.payload.first.hits.hits.0.\_source.spot \>= ctx.payload.second.hits.hits.0.\_source.lbound && ctx.payload.first.hits.hits.0.\_source.spot \<= ctx.payload.second.hits.hits.0.\_source.ubound",  
"lang": "painless"  
}  
},  
"actions": {  
"log": {  
"logging": {  
"level": "info",  
"text": "spot out of bound!"  
}  
}  
}  
}  
}

I met this problem:  
#! Deprecation: [types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/\_doc/{id}, /{index}/\_doc, or /{index}/\_create/{id}).  
{  
"\_index" : "watcher",  
"\_type" : "watch",  
"\_id" : "pricealert",  
"\_version" : 2,  
"result" : "updated",  
"\_shards" : {  
"total" : 2,  
"successful" : 1,  
"failed" : 0  
},  
"\_seq\_no" : 14,  
"\_primary\_term" : 1  
}

Does anyone know from where does it come from?

I try to compare three fields ( one field "spot" from "price-request-2020.01.28" indice with the other two: "lbound" and "ubound" from "mktdata-2020.01.28" indice)  
This is what look like the "mktdata-2020.01.28" indice :  
"hits" : [  
{  
"\_index" : "mktdata-2020.01.28",  
"\_type" : "\_doc",  
"\_id" : "c8Ze628BDeRluIZMFHSD",  
"\_score" : 1.0,  
"\_source" : {  
"twod" : 5.0,  
"@timestamp" : "2020-01-28T08:56:48.165Z",  
"spot" : 1.0,  
"oned" : 3.0  
}

Thanks  
Best regards  
Pierre Jutard

---

<div class="post-metadata">

### Author: ![pierrejutard](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pierrejutard](https://discuss.elastic.co/u/pierrejutard)
#### Post date: [January 28, 2020, 10:19am UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/2 "2020-01-28T10:19:36Z")

</div>

I went through this problem by deleting the:  
{  
"watch":  
{  
at the begining of my watch configuration.

Best,  
Pierre Jutard

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [January 28, 2020, 11:56am UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/3 "2020-01-28T11:56:07Z")

</div>

This looks however as if you are missing an underscore the beginning of the URL, i.e. like `_watcher`

The request you send simply creates an `watcher` index, but is not creating a watch using the put watch API.

---

<div class="post-metadata">

### Author: ![pierrejutard](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pierrejutard](https://discuss.elastic.co/u/pierrejutard)
#### Post date: [January 28, 2020, 1:15pm UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/4 "2020-01-28T13:15:46Z")

</div>

Yes you' re right Alex.

But even with the "\_" the watcher is not created.

With this watcher configuration:

PUT \_watcher/watch/pricealert  
{  
"trigger": {  
"schedule": {  
"interval": "1m"  
}  
},  
"input": {  
"chain": {  
"inputs": [  
{  
"first": {  
"search": {  
"request": {  
"indices": [  
"price-request-2020.01.28"  
],  
"body": {  
"size": 10,  
"query": {  
"match\_all": {}  
}  
}  
}  
}  
}  
},  
{  
"second": {  
"search": {  
"request": {  
"indices": [  
"mktdata-2020.01.28"  
],  
"body": {  
"size": 10,  
"query": {  
"match\_all": {}  
}  
}  
}  
}  
}  
}  
]  
}  
},  
"condition": {  
"script": {  
"source": "return ctx.payload.first.hits.hits.0.\_source.spot \>= 0.8",  
"lang": "painless"  
}  
},  
"actions": {  
"log": {  
"logging": {  
"level": "info",  
"text": "spot out of bound!"  
}  
}  
}  
}

I get this result:

{  
"\_id" : "pricealert",  
"\_version" : 13,  
"\_seq\_no" : 12,  
"\_primary\_term" : 1,  
"created" : false  
}

Do you know why?

When running with POST method this watch i have also this result:  
{  
"\_id" : "pricealert\_77888106-c314-4075-a55e-6a9066ca9d71-2020-01-28T13:13:57.142Z",  
"watch\_record" : {  
"watch\_id" : "pricealert",  
"node" : "p-BVjNRJT\_WIpKDIrre42Q",  
"state" : "failed",  
"status" : {  
"state" : {  
"active" : true,  
"timestamp" : "2020-01-28T13:10:54.115Z"  
},  
"actions" : {  
"log" : {  
"ack" : {  
"timestamp" : "2020-01-28T13:10:54.115Z",  
"state" : "awaits\_successful\_execution"  
}  
}  
},  
"execution\_state" : "failed",  
"version" : 13  
},  
"trigger\_event" : {  
"type" : "manual",  
"triggered\_time" : "2020-01-28T13:13:57.142Z",  
"manual" : {  
"schedule" : {  
"scheduled\_time" : "2020-01-28T13:13:57.142Z"  
}  
}  
},  
"input" : {  
"chain" : {  
"inputs" : [  
{  
"first" : {  
"search" : {  
"request" : {  
"search\_type" : "query\_then\_fetch",  
"indices" : [  
"price-request-2020.01.28"  
],  
"rest\_total\_hits\_as\_int" : true,  
"body" : {  
"size" : 10,  
"query" : {  
"match\_all" : { }  
}  
}  
}  
}  
}  
},  
{  
"second" : {  
"search" : {  
"request" : {  
"search\_type" : "query\_then\_fetch",  
"indices" : [  
"mktdata-2020.01.28"  
],  
"rest\_total\_hits\_as\_int" : true,  
"body" : {  
"size" : 10,  
"query" : {  
"match\_all" : { }  
}  
}  
}  
}  
}  
}  
]  
}  
},  
"condition" : {  
"script" : {  
"source" : "return ctx.payload.first.hits.hits.0.\_source.spot \>= 0.8",  
"lang" : "painless"  
}  
},  
"result" : {  
"execution\_time" : "2020-01-28T13:13:57.142Z",  
"execution\_duration" : 3,  
"input" : {  
"type" : "chain",  
"status" : "success",  
"payload" : {  
"first" : {  
"\_shards" : {  
"total" : 1,  
"failed" : 0,  
"successful" : 1,  
"skipped" : 0  
},  
"hits" : {  
"hits" : [  
{  
"\_index" : "price-request-2020.01.28",  
"\_type" : "\_doc",  
"\_source" : {  
"@timestamp" : "2020-01-28T08:57:34.000Z",  
"subject" : "price request",  
"lbound" : 0.8,  
"ubound" : 1.2  
},  
"\_id" : "dMZe628BDeRluIZM-HR9",  
"\_score" : 1.0  
}  
],  
"total" : 1,  
"max\_score" : 1.0  
},  
"took" : 1,  
"timed\_out" : false  
},  
"second" : {  
"\_shards" : {  
"total" : 1,  
"failed" : 0,  
"successful" : 1,  
"skipped" : 0  
},  
"hits" : {  
"hits" : [  
{  
"\_index" : "mktdata-2020.01.28",  
"\_type" : "\_doc",  
"\_source" : {  
"@timestamp" : "2020-01-28T08:56:48.165Z",  
"spot" : 1.0,  
"oned" : 3.0,  
"twod" : 5.0  
},  
"\_id" : "c8Ze628BDeRluIZMFHSD",  
"\_score" : 1.0  
}  
],  
"total" : 1,  
"max\_score" : 1.0  
},  
"took" : 0,  
"timed\_out" : false  
}  
},  
"chain" : {  
"first" : {  
"type" : "search",  
"status" : "success",  
"payload" : {  
"\_shards" : {  
"total" : 1,  
"failed" : 0,  
"successful" : 1,  
"skipped" : 0  
},  
"hits" : {  
"hits" : [  
{  
"\_index" : "price-request-2020.01.28",  
"\_type" : "\_doc",  
"\_source" : {  
"@timestamp" : "2020-01-28T08:57:34.000Z",  
"subject" : "price request",  
"lbound" : 0.8,  
"ubound" : 1.2  
},  
"\_id" : "dMZe628BDeRluIZM-HR9",  
"\_score" : 1.0  
}  
],  
"total" : 1,  
"max\_score" : 1.0  
},  
"took" : 1,  
"timed\_out" : false  
},  
"search" : {  
"request" : {  
"search\_type" : "query\_then\_fetch",  
"indices" : [  
"price-request-2020.01.28"  
],  
"rest\_total\_hits\_as\_int" : true,  
"body" : {  
"size" : 10,  
"query" : {  
"match\_all" : { }  
}  
}  
}  
}  
},  
"second" : {  
"type" : "search",  
"status" : "success",  
"payload" : {  
"\_shards" : {  
"total" : 1,  
"failed" : 0,  
"successful" : 1,  
"skipped" : 0  
},  
"hits" : {  
"hits" : [  
{  
"\_index" : "mktdata-2020.01.28",  
"\_type" : "\_doc",  
"\_source" : {  
"@timestamp" : "2020-01-28T08:56:48.165Z",  
"spot" : 1.0,  
"oned" : 3.0,  
"twod" : 5.0  
},  
"\_id" : "c8Ze628BDeRluIZMFHSD",  
"\_score" : 1.0  
}  
],  
"total" : 1,  
"max\_score" : 1.0  
},  
"took" : 0,  
"timed\_out" : false  
},  
"search" : {  
"request" : {  
"search\_type" : "query\_then\_fetch",  
"indices" : [  
"mktdata-2020.01.28"  
],  
"rest\_total\_hits\_as\_int" : true,  
"body" : {  
"size" : 10,  
"query" : {  
"match\_all" : { }  
}  
}  
}  
}  
}  
}  
},  
"actions" :   
},  
"exception" : {  
"type" : "script\_exception",  
"reason" : "runtime error",  
"script\_stack" : [  
"return ctx.payload.first.hits.hits.0.\_source.spot \>= 0.8",  
" ^---- HERE"  
],  
"script" : "return ctx.payload.first.hits.hits.0.\_source.spot \>= 0.8",  
"lang" : "painless",  
"caused\_by" : {  
"type" : "null\_pointer\_exception",  
"reason" : null,  
"stack\_trace" : """java.lang.NullPointerException  
at org.elasticsearch.painless.DefBootstrap$MIC.checkLHS(DefBootstrap.java:385)  
at org.elasticsearch.painless.PainlessScript$Script.execute(return ctx.payload.first.hits.hits.0.\_source.spot \>= 0.8:45)  
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:60)  
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:55)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:513)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:320)  
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:159)  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:627)  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:703)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)  
"""  
},  
"stack\_trace" : """ScriptException[runtime error]; nested: NullPointerException;  
at org.elasticsearch.painless.PainlessScript.convertToScriptException(PainlessScript.java:94)  
at org.elasticsearch.painless.PainlessScript$Script.execute(return ctx.payload.first.hits.hits.0.\_source.spot \>= 0.8:45)  
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:60)  
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:55)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:513)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:320)  
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:159)  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:627)  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:703)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)  
Caused by: java.lang.NullPointerException  
at org.elasticsearch.painless.DefBootstrap$MIC.checkLHS(DefBootstrap.java:385)  
... 12 more  
"""  
}  
}  
}

So my question is : Is a watch not created when there is an error in my configuration?

Best,  
Pierre Jutard

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [January 28, 2020, 2:14pm UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/5 "2020-01-28T14:14:05Z")

</div>

What Elasticsearch version is this?

---

<div class="post-metadata">

### Author: ![pierrejutard](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pierrejutard](https://discuss.elastic.co/u/pierrejutard)
#### Post date: [January 28, 2020, 2:21pm UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/6 "2020-01-28T14:21:20Z")

</div>

7.5.2 basic license with 30 day trial extension for the watcher use.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [January 28, 2020, 2:32pm UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/7 "2020-01-28T14:32:09Z")

</div>

Three things.

First, please format your snippets. You can use markdown in here, and this is super hard to read, especially JSON or exceptions. Thanks.

Second, the PUT Watch API response from above with the `pricealert` executed as expected and was stored as a watch.

Third, the third was the output of the exeucte watch API I suppose and has nothing to do with storing the watch. The exception you can read there shows that you tried to access a field, that did not exist. The script is wrong, as you used mustache syntax. Try `ctx.payload.first.hits.hits[0]._source.spot` - also check the result as I do not see a `spot` field in the first payload, but I may be missing it due to the formatting.

hope this helps

---

<div class="post-metadata">

### Author: ![pierrejutard](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pierrejutard](https://discuss.elastic.co/u/pierrejutard)
#### Post date: [January 28, 2020, 3:04pm UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/8 "2020-01-28T15:04:04Z")

</div>

Sorry for the first....

For the second, i understand that this is just updated and not created.

For the third, you're right i have inverted the second with the first.  
But even by following your syntax and make the inversion, it is not working.

This is the result of my two indices that are in the chain inputs:  
First:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/3/0355bc42b41d36b6b980a42690408daf2659eaa8.png)

Second:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/4/b467133cce7b4ca8b6c8bbbbc58e933f79bfad5c.png)

My configuration watch:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/e/0e729b50885a04d71cab1176c9927f5ba9692e20.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/7/371e047bbed60a1d65cf1de84f765e84e8f33734.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/c/5c26d01fc944a8bc75136e163b8d3140421f3063.png)

The result:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/9/299745478b24a9e6d03f6fea98566d53a4d79fcf.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/5/058014e603b624b4e5e125664d96b2c3688074ce.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/2/022b4c94d7adbae85f12969a03c990181c75acd1.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/5/0594ff5ce8abd4f4fe60b23d2c44349922990755.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/9/a98144b68c2511767e2887b7882546fa9729f9f4.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/9/c99a6ebe98b5fa8609becb79007eccdded1a0c09.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/9/f92fea867987144a0e9e568a0687a683bdf18ed5.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2ef72365d832b3d07d5378e55a8222274e85f966.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/1/0158e5ce4a50ac811565cf4af964b5fd260bccc0.png)

Is it a size problem of my search?

Thank you,  
Pierre Jutard

---

<div class="post-metadata">

### Author: ![pierrejutard](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pierrejutard](https://discuss.elastic.co/u/pierrejutard)
#### Post date: [January 28, 2020, 9:45pm UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/9 "2020-01-28T21:45:17Z")

</div>

Yes, it' s a size problem, when setting Size:10 it worked and i go to a cast error after but when you change the equality in inequality it worked definitly.  
Final solution:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a0977cb1f75da0cb3d13489fcde7a9ce6b8607d6.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/6/f61356a6a189ca1b5ea7716ef5d2f476e7e01917.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c2b570232444b4917bac14031d84bc28012741c0.png)

Thanks  
Pierre Jutard

---

<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: [February 25, 2020, 9:45pm UTC](https://discuss.elastic.co/t/watcher-deprecation-types-removal-specifying-types-in-document-index-requests-is-deprecated-use-the-typeless-endpoints-instead-index-doc-id-index-doc-or-index-create-id/216800/10 "2020-02-25T21:45:28Z")

</div>

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