Implementing elasticsearch(1.0x) watcher using Java

I am a novice in ES... I want to work with watcher of ES.
Let's assume a scenario: Let's say I am a doctor. I have data about my patients in ES. Whenever the diagnostic team claims that the patient's health status is deteriorating I should be notified. As I am using Elasticsearch, I want to implement it using watcher in Java. I followed this link but was not able to get a condition using Java. Also, the mustache template is confusing. Is it a good idea to write every logic in a script and access the same script in java class.

Can you please help me with it? If you have any better ideas please suggest which supports the above scenario.

Upon quering ES: http://localhost:9200/clinic/_search?pretty=1 , the response is as below:

> {
>     "took": 1,
>     "timed_out": false,
>     "_shards": {
>         "total": 5,
>         "successful": 5,
>         "failed": 0
>     },
>     "hits": {
>         "total": 1,
>         "max_score": 1,
>         "hits": [{
>             "_index": "clinic",
>             "_type": "patients",
>             "_id": "AWEocy4uDyy-SYauj60G",
>             "_score": 1,
>             "_source": {
>                 "Pdata": [{
>                     "Status": "unhealthy",
>                     "Name": "JohnDoe 1",
>                     "disease": "Typhoid",
>                     "Metrics": {
>                         "BodyMetrics": [{
>                             "symptoms": "fever",
>                             "Type": "c"
>                         }]
>                     },
>                     "Address": "abcd street",
>                     "Date": 2412017,
>                     "severity": "major"
>                 },
>                 {
>                     "Status": "unhealthy",
>                     "Name": "JohnDoe 2",
>                     "disease": "Fatigue",
>                     "Metrics": {
>                         "BodyMetrics": [{
>                             "symptoms": "weakness",
>                             "Type": "a"
>                         }]
>                     },
>                     "Address": "efgh street",
>                     "Date": 22122017,
>                     "severity": "minor"
>                 },
>                 {
>                     "Status": "healthy",
>                     "Name": "JohnDoe 3",
>                     "disease": "HyperTension",
>                     "Metrics": {
>                         "BodyMetrics": [{
>                             "symptoms": "tiredness",
>                             "Type": "d"
>                         }]
>                     },
>                     "Address": "xyz street",
>                     "Date": 2412017,
>                     "severity": "none"
>                 }]
>             }
>         }]
>     }
> }

this is very hard to do without further explanations of your data model. Without knowing it, the question whether you can create a watch basically boils down to one question:

Can you create a search query out of your question/use-case that returns the data needed. If that is the case, you can easily create a watch. But this is the first thing you need to solve, completely independent from watcher.

if that is given, you can proceed and write a watch, share your watch and then we go from there.

This blog post might help you to create a short run/debug loop for watcher

--Alex

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