<?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 Filtering fields via REST API not working with parentheses in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750202#M12005</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I`m running a query via the Splunk REST API (using&amp;nbsp; Python), and need to filter events based on the following requirements:&lt;/P&gt;&lt;P&gt;- Always include events where TITLE&amp;nbsp;is one of: A, B, C, D, E&lt;/P&gt;&lt;P&gt;- Only include events where TITLE=F and FROM=1 OR&amp;nbsp;TITLE=G and FROM=2&lt;/P&gt;&lt;P&gt;This works fine in Splunk Web, but when sent via the REST API the conditional clause for TITLEs F and G don`t get applied correctly&lt;/P&gt;&lt;P&gt;Works via Splunk WEB and REST (without filtering based on FROM)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index System="MySystem*" Title=A OR Title=B OR Title=C OR Title=D OR Title=E OR Title=F OR Title=G&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Works on WEB, not via REST (filtering based on FROM)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index System="MySystem*" Title=A OR Title=B OR Title=C OR Title=D OR Title=E OR (Title=F and FROM=1) OR (Title=G AND FROM=2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I`ve tried to apply the filtering downstream, but the issue persists.&lt;/P&gt;&lt;P&gt;I’m unable to query a saved search because some fields are extracted at search time and aren’t available when accessed via the REST API. As a result, I need to extract those fields directly within the query itself when using the REST API. (Note: the TITLE field is being extracted correctly.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jul 2025 21:15:02 GMT</pubDate>
    <dc:creator>tomapatan</dc:creator>
    <dc:date>2025-07-21T21:15:02Z</dc:date>
    <item>
      <title>Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750202#M12005</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I`m running a query via the Splunk REST API (using&amp;nbsp; Python), and need to filter events based on the following requirements:&lt;/P&gt;&lt;P&gt;- Always include events where TITLE&amp;nbsp;is one of: A, B, C, D, E&lt;/P&gt;&lt;P&gt;- Only include events where TITLE=F and FROM=1 OR&amp;nbsp;TITLE=G and FROM=2&lt;/P&gt;&lt;P&gt;This works fine in Splunk Web, but when sent via the REST API the conditional clause for TITLEs F and G don`t get applied correctly&lt;/P&gt;&lt;P&gt;Works via Splunk WEB and REST (without filtering based on FROM)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index System="MySystem*" Title=A OR Title=B OR Title=C OR Title=D OR Title=E OR Title=F OR Title=G&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Works on WEB, not via REST (filtering based on FROM)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index System="MySystem*" Title=A OR Title=B OR Title=C OR Title=D OR Title=E OR (Title=F and FROM=1) OR (Title=G AND FROM=2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I`ve tried to apply the filtering downstream, but the issue persists.&lt;/P&gt;&lt;P&gt;I’m unable to query a saved search because some fields are extracted at search time and aren’t available when accessed via the REST API. As a result, I need to extract those fields directly within the query itself when using the REST API. (Note: the TITLE field is being extracted correctly.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2025 21:15:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750202#M12005</guid>
      <dc:creator>tomapatan</dc:creator>
      <dc:date>2025-07-21T21:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750203#M12006</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249836"&gt;@tomapatan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is your first "and" lowercase in both examples? This should be uppercase, if its made to uppercase does it behave as expected or do you still get the issue? Im just wondering if the UI does some correction before running the litsearch.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 00:04:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750203#M12006</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-07-22T00:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750213#M12007</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249836"&gt;@tomapatan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you try with below,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search_query = '''
search index=my_index System="MySystem*" (Title=A OR Title=B OR Title=C OR Title=D OR Title=E OR Title=F OR Title=G)
| eval include=if((Title="F" AND FROM="1") OR (Title="G" AND FROM="2") OR match(Title, "^[ABCDE]$"), 1, 0)
| where include=1 '''&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt;&lt;BR /&gt;since you are using python, hope you are using url encoding. Without encoding, the API may misinterpret or strip them.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 04:59:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750213#M12007</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-07-22T04:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750224#M12008</link>
      <description>&lt;P&gt;Thanks, tried to filter downstream without success, unfortunately. I am using URL encoding.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 06:59:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750224#M12008</guid>
      <dc:creator>tomapatan</dc:creator>
      <dc:date>2025-07-22T06:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750228#M12009</link>
      <description>&lt;P&gt;Thanks, "AND" is uppercase in both examples, but the issue persists.&lt;/P&gt;&lt;P&gt;I followed your suggestion and checked the search job properties and the eventSearch changes to:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index System="MySystem*" (Title=A OR Title=B OR Title=C OR Title=D OR Title=E OR (Title=F FROM=1) OR (Title=G FROM=2))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still not working via REST, unfortunately.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 08:05:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750228#M12009</guid>
      <dc:creator>tomapatan</dc:creator>
      <dc:date>2025-07-22T08:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750276#M12010</link>
      <description>&lt;P&gt;1. I'm assuming you are aware of the field names case sensitivity and your field isn't by any chance named From, from or FrOm.&lt;/P&gt;&lt;P&gt;2. Is your search initiated by API running in the same user/app context as the search spawned from web? It smells like some context mismatch resulting in wrongly/not extracted fields.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 19:08:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/750276#M12010</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-07-22T19:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/752595#M12046</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It turns out the issue wasn’t related to parentheses or evaluation order. The real problem was that the FROM field is only available at search time-so it worked in Splunk Web, but not through the REST API. I had to use an inline field extraction to get it working properly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Sep 2025 07:14:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/752595#M12046</guid>
      <dc:creator>tomapatan</dc:creator>
      <dc:date>2025-09-02T07:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/752596#M12047</link>
      <description>&lt;P&gt;While your solution might work your understanding of the problem is wrong. However you're spawning your search (REST, WebUI, scheduler...) it's still a search-time operation (as the name says). So search-time operations are performed (inline extraction is still a search-time extraction BTW). Unless the search is run in wrong context making some knowledge objects unavailable.&lt;/P&gt;&lt;P&gt;That would suggest that your REST-spawned search was run in a different context (app/user) than the webui-spawned one. If the FROM field was extracted using a specific app to which the REST-spawned search had no access or was extracted privately for a specific user and the REST was spawned as another user - that resulted in FROM field not being properly extracted.&lt;/P&gt;&lt;P&gt;Use the btool, Luke.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Sep 2025 07:34:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/752596#M12047</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-09-02T07:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering fields via REST API not working with parentheses</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/752597#M12048</link>
      <description>&lt;P&gt;Interesting-and you're right. The knowledge objects are actually defined in a different app than the one I'm using to run the API calls.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Sep 2025 07:41:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Filtering-fields-via-REST-API-not-working-with-parentheses/m-p/752597#M12048</guid>
      <dc:creator>tomapatan</dc:creator>
      <dc:date>2025-09-02T07:41:07Z</dc:date>
    </item>
  </channel>
</rss>

