<?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 Re: Java SDK - Search strings syntax understanding in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422729#M121387</link>
    <description>&lt;P&gt;Hi! The results are not the point actually. I'm just trying to understand how search strings work using the Java SDK. Why are the different queries that I mentioned not returning anything ?&lt;BR /&gt;
I can't seem to find any information about the syntax. &lt;BR /&gt;
Or am I missing some parameters for them to work ?&lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 11:42:53 GMT</pubDate>
    <dc:creator>michel_hc</dc:creator>
    <dc:date>2018-08-22T11:42:53Z</dc:date>
    <item>
      <title>Java SDK - Search strings syntax understanding</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422725#M121383</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm new with Java SDK and this is what I don't understand in my use of it so far :&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Question 1:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I am using the search command with this search string : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;String query = "search index=_internal | head 2";
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the following results :&lt;/P&gt;

&lt;P&gt;EVENT:********&lt;BR /&gt;
  _bkt --&amp;gt; _internal~12~73571641-98D7-4A7F-BXXXXXXXX&lt;BR /&gt;
  _cd --&amp;gt; 12:738551&lt;BR /&gt;
  _serial --&amp;gt; 0&lt;BR /&gt;
  _raw --&amp;gt; XXX.XXX.XXX.X - admin [21/Aug/2018:16:46:59.961 +0200] "GET /XXX/XXX/XXXX HTTP/1.1" 200 4930 - - - 1ms&lt;BR /&gt;
  splunk_server --&amp;gt; XXX-XXX&lt;BR /&gt;
  index --&amp;gt; _internal&lt;BR /&gt;
  source --&amp;gt; C:\Program Files\Splunk\XXXXXX\splunkd_access.log&lt;BR /&gt;
  _indextime --&amp;gt; 15345510&lt;BR /&gt;
  _subsecond --&amp;gt; .961&lt;BR /&gt;
  linecount --&amp;gt; 1&lt;BR /&gt;
  _si --&amp;gt; XXX-XXX,_internal&lt;BR /&gt;
  host --&amp;gt; XXX-XXX&lt;BR /&gt;
  _sourcetype --&amp;gt; splunkd_access&lt;BR /&gt;
  sourcetype --&amp;gt; splunkd_access&lt;BR /&gt;
  _time --&amp;gt; 2018-08-21T16:46:59.961+02:00&lt;BR /&gt;
EVENT:********&lt;BR /&gt;
  _bkt --&amp;gt; _internal~12~73571641-98D7-4A7F-B8A6-BXXXXXXXX&lt;BR /&gt;
  _cd --&amp;gt; 12:7389098&lt;BR /&gt;
  _serial --&amp;gt; 1&lt;BR /&gt;
  _raw --&amp;gt; 185.162.209.1 - admin [21/Aug/2018:16:46:59.705 +0200] "POST /XXX/XXX/XXXHTTP/1.1" 200 170 - - - 10ms&lt;BR /&gt;
  splunk_server --&amp;gt; XXX-XXX&lt;BR /&gt;
  index --&amp;gt; _internal&lt;BR /&gt;
  source --&amp;gt; C:\Program Files\Splunk\XXX\splunkd_access.log&lt;BR /&gt;
  _indextime --&amp;gt; 1534865515&lt;BR /&gt;
  _subsecond --&amp;gt; .705&lt;BR /&gt;
  linecount --&amp;gt; 1&lt;BR /&gt;
  _si --&amp;gt; XXX-XXX,_internal&lt;BR /&gt;
  host --&amp;gt; XXX-XXX&lt;BR /&gt;
  _sourcetype --&amp;gt; splunkd_access&lt;BR /&gt;
  sourcetype --&amp;gt; splunkd_access&lt;BR /&gt;
  _time --&amp;gt; 2018-08-21T16:46:59.705+02:00&lt;/P&gt;

&lt;P&gt;Can you tell me why this search string :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;String query = "search index=_internal _serial=0 | head 2 ";
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;does not return anything ? Because I expected to retrieve the first EVENT&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Question 2:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Does the search string always have to mention an index name ? Because I thought searching by keyword would work with the Java SDK and it is not (for example : "search _serial=0" returns nothing). &lt;BR /&gt;
In general, how different are the syntax that we use in the GUI version and the command lines ? Are the boolean operators accepted in command lines for example ?&lt;BR /&gt;
My main goal is allowing the user to use my app as he is used to in the GUI version (or as close as possible).&lt;/P&gt;

&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:00:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422725#M121383</guid>
      <dc:creator>michel_hc</dc:creator>
      <dc:date>2020-09-29T21:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Java SDK - Search strings syntax understanding</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422726#M121384</link>
      <description>&lt;P&gt;@michel_hc instead on depending on SDK, can you not do &lt;CODE&gt;| head 1&lt;/CODE&gt; to get first result instead of head 2?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 17:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422726#M121384</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-21T17:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Java SDK - Search strings syntax understanding</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422727#M121385</link>
      <description>&lt;P&gt;Hi! My app is in Java and I chose to use this SDK to integrate Splunk to it so it relies on it. But I'm just playing around with it for the moment as I'm new with it and all I can see this far is that search strings that I pass to the SDK make sense to me but no results are returned ; I don't see why the second query wouldn't work. &lt;/P&gt;

&lt;P&gt;I'm just trying to understand what's wrong and what syntax I should use because these don't work either:&lt;BR /&gt;
String query = "search index=_internal _serial=0 | head 1";&lt;BR /&gt;
String query = "search index=_internal _serial=0";&lt;BR /&gt;
String query = "search index=_internal _serial='0'";&lt;BR /&gt;
String query = "search index=_internal AND _serial=0";&lt;BR /&gt;
String query = "search index=_internal and _serial=0";&lt;/P&gt;

&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:00:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422727#M121385</guid>
      <dc:creator>michel_hc</dc:creator>
      <dc:date>2020-09-29T21:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Java SDK - Search strings syntax understanding</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422728#M121386</link>
      <description>&lt;P&gt;I meant the following without &lt;CODE&gt;_serial=0&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;String query = "search index=_internal | head 1";
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Aug 2018 10:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422728#M121386</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-22T10:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Java SDK - Search strings syntax understanding</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422729#M121387</link>
      <description>&lt;P&gt;Hi! The results are not the point actually. I'm just trying to understand how search strings work using the Java SDK. Why are the different queries that I mentioned not returning anything ?&lt;BR /&gt;
I can't seem to find any information about the syntax. &lt;BR /&gt;
Or am I missing some parameters for them to work ?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 11:42:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422729#M121387</guid>
      <dc:creator>michel_hc</dc:creator>
      <dc:date>2018-08-22T11:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Java SDK - Search strings syntax understanding</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422730#M121388</link>
      <description>&lt;P&gt;If I bring you to SPL alone (without Splunk SDK), the search query that you are building looks at Splunk's _internal index and tries to find an internal field &lt;CODE&gt;_serial&lt;/CODE&gt; with value 0. Which from my understanding does not exist. So you do not get any results back. &lt;/P&gt;

&lt;P&gt;For example Just take following two queries as is and try running in Splunk Search:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;search index=_internal | head 1&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;search index=_internal _serial=0 | head 1&lt;/CODE&gt;
PS: Splunk Search by default adds a &lt;CODE&gt;search&lt;/CODE&gt; keyword before our query in case it is not a generating command i.e. starting with pipe &lt;CODE&gt;|&lt;/CODE&gt; like &lt;CODE&gt;| makeresults&lt;/CODE&gt;. So, it will remove &lt;CODE&gt;search&lt;/CODE&gt; command from the search string when you paste in Splunk Search bar.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:58:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422730#M121388</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T20:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Java SDK - Search strings syntax understanding</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422731#M121389</link>
      <description>&lt;P&gt;Ok, I have the expected results with this following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;String query = "search index=_internal | where _serial=0";
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I'm just wondering if it is possible to make a search without mentioning an index.&lt;BR /&gt;
For example, what if I wanted to know the indexes containing a certain keyword, how would I do ? &lt;BR /&gt;
Or what if I wanted to list all the available indexes ?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 11:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Java-SDK-Search-strings-syntax-understanding/m-p/422731#M121389</guid>
      <dc:creator>michel_hc</dc:creator>
      <dc:date>2018-08-23T11:58:18Z</dc:date>
    </item>
  </channel>
</rss>

