<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by shardul Negi on Medium]]></title>
        <description><![CDATA[Stories by shardul Negi on Medium]]></description>
        <link>https://medium.com/@negimags?source=rss-972259f10b7e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by shardul Negi on Medium</title>
            <link>https://medium.com/@negimags?source=rss-972259f10b7e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:06:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@negimags/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Updating Elastic Search from Kibana and implementing in golang]]></title>
            <link>https://negimags.medium.com/updating-elastic-search-from-kibana-5bf84c1e0281?source=rss-972259f10b7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bf84c1e0281</guid>
            <category><![CDATA[kibana]]></category>
            <category><![CDATA[elastic-kibana]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[shardul Negi]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 22:04:00 GMT</pubDate>
            <atom:updated>2023-08-21T14:37:10.722Z</atom:updated>
            <content:encoded><![CDATA[<p>Updating Elastic search record is cumbersome and the tag “lang”-&gt;”painless” is not painless at all if not done correctly.</p><p>The following is for trying in Kibana. Its always a good practice to test it in theory and then implement it in language of your choice</p><p><strong>Theory:</strong></p><p>Try it on devTools first and read the documentation. Always test your queries with test data first in test env or dev env before.</p><p><a href="https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_creating_an_index">https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_creating_an_index</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TO2y0EPIqKiB2V_L9qBmFw.png" /></figure><h3><strong>1: Get a record</strong></h3><blockquote><strong>GET &lt;name&gt;/_search<br>{<br> “query”: {<br> “match_phrase”: {<br> “&lt;ID tag&gt;”: “&lt;ID&gt;”<br> }<br> }<br>}</strong></blockquote><h3><strong>2: Delete(Be very careful here if testing in Production DB)</strong></h3><blockquote><strong>POST &lt;name&gt;/_delete_by_query<br>{<br> “query”: {<br> “match”: {<br> “&lt;tag&gt;”: “&lt;value&gt;”<br> }<br> }<br>}</strong></blockquote><h3><strong>3: Update query</strong></h3><blockquote><strong>POST &lt;name&gt;/_update_by_query <br>{<br> “query”: {<br> “match_phrase”: {<br> “tag”: “&lt;Value&gt;”<br> }<br> }, <br> “script”: {<br> “source”: “ctx._source[‘&lt;ID&gt;’] = ‘&lt;Value&gt;’”,<br> “lang”: “painless”<br> }<br>}</strong></blockquote><h3><strong>Go lang code to implement</strong></h3><h3><strong>GET:</strong></h3><p><strong>func StoreDataElasticSearch(index string, data []byte) (err error) {</strong></p><p><strong>elasticClient, err := createElasticSearchClient()</strong></p><p><strong>if err != nil {</strong></p><p><strong>return</strong></p><p><strong>}</strong></p><p><strong>req := esapi.IndexRequest{</strong></p><p><strong>Index: index,</strong></p><p><strong>DocumentID: uuid.New().String(),</strong></p><p><strong>Body: bytes.NewReader(data),</strong></p><p><strong>Refresh: “true”,</strong></p><p><strong>}</strong></p><p><strong>res, err := req.Do(context.Background(), elasticClient)</strong></p><p><strong>if err != nil {</strong></p><p><strong>panic(err.Error())</strong></p><p><strong>}</strong></p><p><strong>defer res.Body.Close()</strong></p><p><strong>_, err = ioutil.ReadAll(res.Body)</strong></p><p><strong>if err != nil {</strong></p><p><strong>panic(err.Error())</strong></p><p><strong>}</strong></p><p><strong>return</strong></p><p><strong>}</strong></p><p>Update:</p><h3><strong>Updating elastic query with stripe ID</strong></h3><blockquote><strong>func UpdateByQuery(index, idempotencyKey, eventType string) error {</strong></blockquote><blockquote><strong>esClient, err := createElasticSearchClient()</strong></blockquote><blockquote><strong>if err != nil {</strong></blockquote><blockquote><strong>return err</strong></blockquote><blockquote><strong>}</strong></blockquote><blockquote><strong>query := `{</strong></blockquote><blockquote><strong>“query”: {</strong></blockquote><blockquote><strong>“match_phrase”: {</strong></blockquote><blockquote><strong>“StripeUuid”: “%s”</strong></blockquote><blockquote><strong>}</strong></blockquote><blockquote><strong>},</strong></blockquote><blockquote><strong>“script”: {</strong></blockquote><blockquote><strong>“source”: “ctx._source[‘Status’] = ‘%s’”,</strong></blockquote><blockquote><strong>“lang”: “painless”</strong></blockquote><blockquote><strong>}</strong></blockquote><blockquote><strong>}`</strong></blockquote><blockquote><strong>query = fmt.Sprintf(query, idempotencyKey, eventType)</strong></blockquote><blockquote><strong>req := esapi.UpdateByQueryRequest{</strong></blockquote><blockquote><strong>Index: []string{index},</strong></blockquote><blockquote><strong>Body: strings.NewReader(query),</strong></blockquote><blockquote><strong>}</strong></blockquote><blockquote><strong>res, err := req.Do(context.Background(), esClient)</strong></blockquote><blockquote><strong>if err != nil {</strong></blockquote><blockquote><strong>return err</strong></blockquote><blockquote><strong>}</strong></blockquote><blockquote><strong>defer res.Body.Close()</strong></blockquote><blockquote><strong>if res.IsError() {</strong></blockquote><blockquote><strong>return fmt.Errorf(“failed to update documents: %s”, res.Status())</strong></blockquote><blockquote><strong>}</strong></blockquote><blockquote><strong>return nil</strong></blockquote><blockquote><strong>}</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bf84c1e0281" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Converting XML To JSON and write to a File in IBM Integration Bus]]></title>
            <link>https://negimags.medium.com/converting-xml-to-json-and-write-to-a-file-in-ibm-integration-bus-ff13466d5203?source=rss-972259f10b7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff13466d5203</guid>
            <category><![CDATA[ibm-integration-bus]]></category>
            <dc:creator><![CDATA[shardul Negi]]></dc:creator>
            <pubDate>Tue, 12 Jan 2021 19:55:51 GMT</pubDate>
            <atom:updated>2021-01-14T02:13:22.650Z</atom:updated>
            <content:encoded><![CDATA[<p>I have listed a demo for converting XML to JSON file output using IIB integration bus. Since, the tool itself is paid I hope the below example can help some to set up.</p><h4><strong>Considerations and Requirements</strong></h4><p>1:IIB Integration Toolkit 10.0.0</p><p>2: MQ explorer Eclipse</p><h4>Steps to Follow:</h4><p>a) Create a new application and create a sub-flow. The primary of aim of what we will be achieving is given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1Y3FBuE5ReRdJm_B4CR4A.png" /></figure><p>Below are the components involved in the same.</p><p>1: <strong>HTTPInput/HttpOutput:</strong> It will take the XML as input from the HTTP Request. I will be using Postman for the request but, you can use SOAP as well. HttpOutput is for responding with the output.</p><p>2:<strong> Filter:</strong> This will be used to write a ESQL for differentiating the XML and channelize it to the output nodes according to the requirements. eg. the XML I will have used a simple one below</p><p>Here, 1 will write to a file in local, 2 will sent it to a MQ and if none and exception will be generated</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*agOuPlbqLKyy9P4ngGqHEA.png" /><figcaption>XML example used in the flow.</figcaption></figure><p>3: <strong>Compute: </strong>Now, this node is basically used to write the main conversion logic for the same.</p><p>4: <strong>File Output: </strong>File output node is used for saving the json or any output to text file or any type of file.</p><p>Now, I have listed the compute node and filter logic for to run the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1zuOzvjfBqLDGeXEXr9l7A.png" /><figcaption>Filter Node logic</figcaption></figure><p>Here, in filter we have bifurcated the XML response as 1 and 2. If 1 it will take the route 1 else 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*Y0bjnDEPhn8yWiOB5LsE_g.png" /><figcaption>For Compute Nodes</figcaption></figure><p>Likewise for the compute nodes you can take help of the following code. Here, it simply takes into account the XML structure and parses it to JSON. You can set it according the tree structure also.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WnMf98f4Zu94dcEN8tyAjA.png" /><figcaption>Exception code for Java compute Node</figcaption></figure><p>Lastly, write the code above in figure for Java compute Node. This snippet is for the exception case if neither of the cases 1 or 2 matches.</p><blockquote>Note: Please refer the first screen shot of the overview to understand the flow post that.</blockquote><p>Lastly, open Postman and write follow this steps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFdEuW8yTCUQW1sJsC1AIg.png" /><figcaption>Run this code after starting the integration Node</figcaption></figure><blockquote>Note: Set HttpInput endpoint initially like the figure below, since that will help to call the HTTP request.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8x7h--YrnYwk5nFrKty3Iw.png" /><figcaption>Configuring the HttpInput Node</figcaption></figure><h4>Conclusion</h4><p>If done you can follow the same steps with MQ as input. It gets easy if you follow the IBM documentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff13466d5203" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>