<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic replace string (using map/object) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/529820#M149672</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;is there anyway to define a map / object. IE { '123': 'something',&amp;nbsp; '1234', 'anotherThing' } and then replace strings with '123' with 'something' and strings with '1234' with 'anotherThing'?&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2020 20:01:27 GMT</pubDate>
    <dc:creator>posix</dc:creator>
    <dc:date>2020-11-17T20:01:27Z</dc:date>
    <item>
      <title>replace string (using map/object)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/529820#M149672</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;is there anyway to define a map / object. IE { '123': 'something',&amp;nbsp; '1234', 'anotherThing' } and then replace strings with '123' with 'something' and strings with '1234' with 'anotherThing'?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 20:01:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/529820#M149672</guid>
      <dc:creator>posix</dc:creator>
      <dc:date>2020-11-17T20:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: replace string (using map/object)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/530043#M149747</link>
      <description>&lt;P&gt;your question is not quite clear.&lt;/P&gt;&lt;P&gt;may be you find below is helpful.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults 
| eval object="{ '123': 'something',  '1234', 'anotherThing' }"
| rex mode=sed "s/'123'/'something'/g" field=object
| rex mode=sed "s/'1234'/'anotherThing'/g" field=object&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 Nov 2020 07:42:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/530043#M149747</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-11-19T07:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: replace string (using map/object)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/530045#M149749</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/129407"&gt;@thambisetty&lt;/a&gt;&amp;nbsp; thanks for the response. let me clarify the question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a field called image_name which is a string. the string is like '123_456_789_10'. and i want to decode the string from an object. like this {123: 'something', 456: 'something2', 789: 'something3', 10: 'something5'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i wand to replace the values of the image_name field with the values of the object so the string will be like: something_something2_something3_something5.&lt;/P&gt;&lt;P&gt;hopefully this makes it clearer.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 07:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/530045#M149749</guid>
      <dc:creator>posix</dc:creator>
      <dc:date>2020-11-19T07:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: replace string (using map/object)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/530318#M149840</link>
      <description>&lt;P&gt;You can do that easily using rex mode=sed. but if you have very large number of replacements then rex would not be a right fit.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;using rex if you have small number of replacements:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval image_name="123_456_789_10"
| rex mode=sed "s/123/something/g" field=image_name
| rex mode=sed "s/456/something2/g" field=image_name
| rex mode=sed "s/789/something3/g" field=image_name
| rex mode=sed "s/10/something5/g" field=image_name&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;using kv-store lookup if you have very large number of replacements:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;you need to define kv-store lookup&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;you need to have two fields let's call it: number and text&lt;/LI&gt;&lt;LI&gt;The kv-store lookup should look like below:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thambisetty_0-1606026508886.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12011i9415301EACD45666/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thambisetty_0-1606026508886.png" alt="thambisetty_0-1606026508886.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&amp;nbsp;The final search looks like below:&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval image_name="123_456_789_10"
| makemv image_name delim="_"
| lookup test_mv_final number as image_name OUTPUT text as decode_image_name
| eventstats list(decode_image_name) as decode_image_name delim="_"
| mvcombine decode_image_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Reason for using kv-store lookup rather csv lookup is to perform lookup against multi value field. lookups are not aware of multivalue fields.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 06:31:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-string-using-map-object/m-p/530318#M149840</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-11-22T06:31:24Z</dc:date>
    </item>
  </channel>
</rss>

