<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ELK Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/elk/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Mon, 21 Oct 2019 14:14:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.12</generator>
	<item>
		<title>How to Install ELK Stack on Centos 8?</title>
		<link>https://www.osradar.com/how-to-install-elk-stack-on-centos-8/</link>
					<comments>https://www.osradar.com/how-to-install-elk-stack-on-centos-8/#respond</comments>
		
		<dc:creator><![CDATA[sabi]]></dc:creator>
		<pubDate>Tue, 22 Oct 2019 02:17:25 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Centos 8]]></category>
		<category><![CDATA[Elasticsearch]]></category>
		<category><![CDATA[ELK]]></category>
		<category><![CDATA[Kibana]]></category>
		<category><![CDATA[Logstash]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=14775</guid>

					<description><![CDATA[<p>What is ELK?&#160; ELK is the group of three open source projects in Linux.&#160; Elastic Search, Logstash and Kibana respectively. Before going into depth let&#8217;s have a short definition about these: Elasticsearch: This is an open source distribution, reliable, scalable, easy to use and flexible Lucene library based search engine.&#160;It provides multitenant-capable text with an [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-elk-stack-on-centos-8/">How to Install ELK Stack on Centos 8?</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h3><strong> What is ELK?&nbsp;</strong></h3>



<p>ELK is the group of three open source projects in Linux.&nbsp; Elastic Search, Logstash and Kibana respectively. Before going into depth let&#8217;s have a short definition about these:</p>



<h3><strong>Elasticsearch: </strong></h3>



<p>This is an open source distribution, reliable, scalable, easy to use and flexible Lucene library based search engine.&nbsp;It provides multitenant-capable text with an HTTP web interface.</p>



<h3><strong>Logstash: </strong></h3>



<p>It is an open source tool used to store data, collect information, and store it for further use. Kibana is used to retrieve the logs stored by Logstash.</p>



<h3><strong>Kibana:</strong></h3>



<p> Let&#8217;s you transform your data into your own format or specific shape like charts and graphs in Elasticsearch.&nbsp;</p>



<p>So, in this article we will cover the following :</p>



<ul><li><strong>How to Install Java on Centos 8</strong></li></ul>



<ul><li><strong>How to add ELK repository to Centos 8</strong></li></ul>



<ul><li><strong>How to install and Configure Elasticsearch&nbsp;</strong></li></ul>



<ul><li><strong>How to instaall and configure Kibana on Centos 8</strong></li></ul>



<ul><li><strong>How to install and configure Logstash on Centos 8</strong></li></ul>



<ul><li><strong>How to install other ELK tools(Optional)</strong></li></ul>



<h3><strong>Step 1: Install Java on Centos 8</strong></h3>



<p>Before installing Elasticsearch we must have java installed on our system as Elasticsearch depends on java.&nbsp; So install it before further proceeding.</p>



<p><a href="https://www.osradar.com/install-java-on-rhel-8-centos-8-oracle-linux-8/">How to install Java 11 (OpenJdk 11 on RHEL / Centos 8</a></p>



<h3><strong>Step 2: Add ELK repository to Centos 8</strong></h3>



<p>After installing java, add ELK repository&nbsp; to Centos 8 and run the following command as Sudo.</p>



<h3><strong>For</strong> <strong>Elasticsearch 7.x&nbsp;</strong></h3>



<p class="has-background has-cyan-bluish-gray-background-color">cat &lt;&lt;EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo</p>



<p class="has-background has-cyan-bluish-gray-background-color">[elasticsearch -7.x]</p>



<p class="has-background has-cyan-bluish-gray-background-color">name=Elasticsearch repository for 7.x packages</p>



<p class="has-background has-cyan-bluish-gray-background-color">baseurl=https://artifacts.elasticsearch.co/packages/7.x/yum</p>



<p class="has-background has-cyan-bluish-gray-background-color">gpgcheck=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticse</p>



<p class="has-background has-cyan-bluish-gray-background-color">enabled=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">autorefresh=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">type=rpm-md</p>



<p class="has-background has-cyan-bluish-gray-background-color">EOF</p>



<h3><strong> For Elasticsearch 6.x </strong></h3>



<p class="has-background has-cyan-bluish-gray-background-color">cat &lt;&lt;EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo</p>



<p class="has-background has-cyan-bluish-gray-background-color">[elasticsearch -6.x]</p>



<p class="has-background has-cyan-bluish-gray-background-color">name=Elasticsearch repository for 6.x packages</p>



<p class="has-background has-cyan-bluish-gray-background-color">baseurl=https://artifacts.elasticsearch.co/packages/6.x/yum</p>



<p class="has-background has-cyan-bluish-gray-background-color">gpgcheck=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticse</p>



<p class="has-background has-cyan-bluish-gray-background-color">enabled=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">autorefresh=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">type=rpm-md</p>



<p class="has-background has-cyan-bluish-gray-background-color">EOF</p>



<h3><strong>For</strong> <strong>Elasticsearch 5.x</strong></h3>



<p class="has-background has-cyan-bluish-gray-background-color">cat &lt;&lt;EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo</p>



<p class="has-background has-cyan-bluish-gray-background-color">[elasticsearch -5.x]</p>



<p class="has-background has-cyan-bluish-gray-background-color">name=Elasticsearch repository for 5.x packages</p>



<p class="has-background has-cyan-bluish-gray-background-color">baseurl=https://artifacts.elasticsearch.co/packages/5.x/yum</p>



<p class="has-background has-cyan-bluish-gray-background-color">gpgcheck=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticse</p>



<p class="has-background has-cyan-bluish-gray-background-color">enabled=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">autorefresh=1</p>



<p class="has-background has-cyan-bluish-gray-background-color">type=rpm-md</p>



<p class="has-background has-cyan-bluish-gray-background-color">EOF</p>



<p>After doing so, import GPG key</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo rpm &#8211;import https://artifacts.elastic.co/GPG-KEY-elasticsearch</p>



<p>

Now,&nbsp; clear and update your YUM package index.&nbsp;

</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo yum clean all</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo yum makecache</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="780" height="563" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/elasticsearch-repo.png" alt="" class="wp-image-14787" srcset="https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-repo.png 780w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-repo-300x217.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-repo-768x554.png 768w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-repo-324x235.png 324w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-repo-696x502.png 696w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-repo-582x420.png 582w" sizes="(max-width: 780px) 100vw, 780px" /></figure></div>



<h3><strong>Step 3: Install and Configure Elasticsearch</strong></h3>



<p> As we have done with Elasticsearch repository and now it&#8217;s ready to use. Now make sure to run this command to install Elasticsearch.</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo yum -y install elasticsearch</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="799" height="588" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/elasticsearch-installed.png" alt="" class="wp-image-14816" srcset="https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-installed.png 799w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-installed-300x221.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-installed-768x565.png 768w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-installed-80x60.png 80w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-installed-696x512.png 696w, https://www.osradar.com/wp-content/uploads/2019/10/elasticsearch-installed-571x420.png 571w" sizes="(max-width: 799px) 100vw, 799px" /></figure></div>



<p>Double-check that installation completed successfully.&nbsp;</p>



<p class="has-background has-cyan-bluish-gray-background-color">rpm -qi elasticsearch</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="734" height="503" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/query-es.png" alt="" class="wp-image-14817" srcset="https://www.osradar.com/wp-content/uploads/2019/10/query-es.png 734w, https://www.osradar.com/wp-content/uploads/2019/10/query-es-300x206.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/query-es-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2019/10/query-es-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2019/10/query-es-696x477.png 696w, https://www.osradar.com/wp-content/uploads/2019/10/query-es-613x420.png 613w" sizes="(max-width: 734px) 100vw, 734px" /></figure></div>



<p>Set up the JVM options like memory limits and others according to your own needs. For this edit the following file:</p>



<p>Here we have set up maximum size of total heap space.</p>



<p class="has-background has-cyan-bluish-gray-background-color"> /etc/elasticsearch/jvm.options</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="716" height="111" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/heapsize.png" alt="" class="wp-image-14818" srcset="https://www.osradar.com/wp-content/uploads/2019/10/heapsize.png 716w, https://www.osradar.com/wp-content/uploads/2019/10/heapsize-300x47.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/heapsize-696x108.png 696w" sizes="(max-width: 716px) 100vw, 716px" /></figure></div>



<p>You can adjust according to your system requirements.&nbsp;</p>



<p>Now,&nbsp; start and enable the Elasticsearch services.</p>



<figure class="wp-block-image"><img loading="lazy" width="737" height="130" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/enable-elasticsearch-services.png" alt="" class="wp-image-14819" srcset="https://www.osradar.com/wp-content/uploads/2019/10/enable-elasticsearch-services.png 737w, https://www.osradar.com/wp-content/uploads/2019/10/enable-elasticsearch-services-300x53.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/enable-elasticsearch-services-696x123.png 696w" sizes="(max-width: 737px) 100vw, 737px" /></figure>



<p>Make sure these are properly working.&nbsp;</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="756" height="347" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/test-to-verify-elasticsearch.png" alt="" class="wp-image-14820" srcset="https://www.osradar.com/wp-content/uploads/2019/10/test-to-verify-elasticsearch.png 756w, https://www.osradar.com/wp-content/uploads/2019/10/test-to-verify-elasticsearch-300x138.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/test-to-verify-elasticsearch-696x319.png 696w" sizes="(max-width: 756px) 100vw, 756px" /></figure></div>



<p>Let&#8217;s create a test index.</p>



<p class="has-background has-cyan-bluish-gray-background-color">curl -X PUT &#8220;http://127.0.0.1:9200/mytest_index&#8221;</p>



<h3><strong>Step 4: Install / Configure Kibana on Centos 8</strong></h3>



<p>From added Elasticsearch repository download and install kibana.&nbsp;</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo yum -y install kibana</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="729" height="408" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/installed-kibana.png" alt="" class="wp-image-14823" srcset="https://www.osradar.com/wp-content/uploads/2019/10/installed-kibana.png 729w, https://www.osradar.com/wp-content/uploads/2019/10/installed-kibana-300x168.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/installed-kibana-696x390.png 696w" sizes="(max-width: 729px) 100vw, 729px" /></figure></div>



<p>Configure it after installation completed.&nbsp;</p>



<p class="has-background has-cyan-bluish-gray-background-color"><strong>sudo vim /etc/kibana/kibana.yml </strong><br> server.host: &#8220;<strong>0.0.0.0</strong>&#8220;<br> server.name: &#8220;<strong>kibana.example.com&#8221;</strong><br> elasticsearch.url: &#8220;<strong>http://localhost:9200</strong>&#8220;</p>



<p>Set up other settings to your own requirements and start kibana services.</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo systemctl enable &#8211;now kibana</p>



<p>Visit&nbsp;<a href="http://osradar.com" target="_blank" rel="noreferrer noopener" aria-label="http://ip-address:5601 (opens in a new tab)">http://ip-address:5601</a>&nbsp;to open kibana dashboard&nbsp;</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="714" height="252" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/10/kibana-dashboard.png" alt="" class="wp-image-14822" srcset="https://www.osradar.com/wp-content/uploads/2019/10/kibana-dashboard.png 714w, https://www.osradar.com/wp-content/uploads/2019/10/kibana-dashboard-300x106.png 300w, https://www.osradar.com/wp-content/uploads/2019/10/kibana-dashboard-696x246.png 696w" sizes="(max-width: 714px) 100vw, 714px" /></figure></div>



<p>If you have firewall service active make sure to allow TCP port 5601.</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo firewall-cmd &#8211;add-port=5601/tcp &#8211;permanent<br>
sudo firewall-cmd &#8211;reload</p>



<h3><strong>Step 4: Install / Configure Logstash on Centos 8</strong></h3>



<p>The last step is to install and configure Logstash which will act like a centralized logs server for your client systems and runs an agent like filebeat.</p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo yum -y install logstash</p>



<p>Customize settings under the following directory: <strong>/etc/logstash/conf.d</strong>/ For further information you can check out <a href="https://www.elastic.co/guide/en/logstash/current/index.html">Logstash configuration manual.&nbsp;</a></p>



<h3><strong>Step 5: Install other ELK tools &#8211; (optional)&nbsp;</strong></h3>



<p>Some of these tools help you to work smoothly.</p>



<h4><strong>Filebeat:</strong></h4>



<p>It makes things simple by following lightweight way to forward and centralized logs and files.&nbsp;</p>



<h4><strong>Metricbeat:</strong></h4>



<p>Helps you to send and collect metrics from your systems and services, from CPU to memory,&nbsp; Redis to NGINX,&nbsp; and many more.&nbsp; It&#8217;s also a lightweight way to access system and services statistics.</p>



<h4><strong>Packetbeat:</strong></h4>



<p>Packetbeat provides a lightweight way for Network Data to increase performance.</p>



<h4><strong>Heartbeat:</strong></h4>



<p>Monitors the up time of Services. Helps you to know Availability of services.&nbsp;</p>



<h4><strong>Auditbeat:</strong></h4>



<p>Useful for auditing the activities and processes on your system by users.&nbsp;The tools we have discussed so far can be installed with the give command one time or you can install individually by this command. </p>



<p class="has-background has-cyan-bluish-gray-background-color">sudo yum install filebeat auditbeat metricbeat packetbeat heartbeat-elastic</p>



<p>These add-on tools help you better experience.To configure any tool you can check&nbsp; <a href="https://www.elastic.co/guide/index.html">official ELK stack documentation.</a></p>



<p>Hope you are all done!&nbsp;&nbsp;If have any queries regarding this tutorial leave a comment! </p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-elk-stack-on-centos-8/">How to Install ELK Stack on Centos 8?</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-install-elk-stack-on-centos-8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Elasticsearch DSL Query Examples</title>
		<link>https://www.osradar.com/elasticsearch-dsl-query-examples/</link>
					<comments>https://www.osradar.com/elasticsearch-dsl-query-examples/#respond</comments>
		
		<dc:creator><![CDATA[osradar_editor]]></dc:creator>
		<pubDate>Fri, 25 Jan 2019 15:02:06 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Elasticsearch]]></category>
		<category><![CDATA[ELK]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=9662</guid>

					<description><![CDATA[<p>If you have been reading my previous posts of ELK stack, you should now be comfortable on How to setup Elasaticsearch Node. What options do we have to ingest data into Elasticsearch database. Elasticsearch uses an entity called &#8220;INDEX&#8221; to store data. Every message that&#8217;s gets stored is a &#8220;Document&#8221; at Elasticsearch. And even we [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/elasticsearch-dsl-query-examples/">Elasticsearch DSL Query Examples</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you have been reading my previous <a href="https://www.osradar.com/setting-up-elasticsearch-on-linux">posts</a> of ELK stack, you should now be comfortable on</p>
<ul>
<li>How to setup Elasaticsearch Node.</li>
<li>What options do we have to ingest data into Elasticsearch database.</li>
<li>Elasticsearch uses an entity called &#8220;INDEX&#8221; to store data.</li>
<li>Every message that&#8217;s gets stored is a &#8220;Document&#8221; at Elasticsearch.</li>
<li>And even we know that using Kibana it is possible to view those data back for analysis.</li>
</ul>
<p>In this post, I am going to cover the native Query language that Elasticsearch use to search data. It is DSL (Domain Specific Language).</p>
<p><img loading="lazy" class="alignnone  wp-image-9743" src="https://www.osradar.com/wp-content/uploads/2019/01/query-300x127.png" alt="" width="484" height="205" srcset="https://www.osradar.com/wp-content/uploads/2019/01/query-300x127.png 300w, https://www.osradar.com/wp-content/uploads/2019/01/query.png 668w" sizes="(max-width: 484px) 100vw, 484px" /></p>
<h3>REST API:</h3>
<p>9200/tcp is one of the network communication socket that Elasticsearch use. And when running, Elasticsearch expose its REST API on this port for external communication and that is what we can connect with to perform these DSL queries. This API is build on top of HTTP protocol, so its aware any http calls, for example, GET, POST, PUT..</p>
<p>If you are wondering on which client that will support executing these queries, well, there are 3rd party applications, such as &#8220;Postman&#8221;. However, since we already have Kibana Installed, let&#8217;s check that on how to access the REST API.</p>
<p></p>
<ul>
<li>Since Kibana is aware the Elasticsearch node url, it is not required to mention in the query itself, like if you are working on 3rd party tool.</li>
</ul>
<p></p>
<p>&nbsp;<strong>match_all</strong> Query:</p>
<p>If we don&#8217;t know what to search, but we need to see every document inside of a INDEX, this query comes handy.</p>
<pre class="lang:sh decode:true">GET 192.168.0.1:9200/index_name/_search

{
  "size": 1,
  "query": {
    "match_all": {}
  }
}</pre>
<ul>
<li><strong>index_name</strong> =&gt; on which index that perform the query</li>
<li><strong>_search</strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; one of the API endpoint that elasticsearch exposes. _search of course is what provide the search facility.</li>
<li><strong>{}&nbsp;</strong> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; everything inside of the curly braces will be HTTP body</li>
<li><strong>size</strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; number of matched document that need to filter out.</li>
<li><strong>match_all</strong>&nbsp; &nbsp; &nbsp;=&gt; this is a catch all statement where anything inside the &#8220;<em>index_name</em>&#8221; INDEX we would be able to see.</li>
</ul>
<p></p>
<h4><strong>exists</strong> Query:</h4>
<p>We know that Elasticsearch is a Json store, so if we know the exact FieldName that the document we are searching upon, this query comes handy.</p>
<pre class="lang:sh decode:true">GET 192.168.0.1:9200/index_name/_search

{
  "query": {
    "exists": {
      "field": "firstName"
    }
  }
}</pre>
<ul>
<li><strong>field&nbsp;</strong> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; We are searching any document inside the &#8220;<em>index_name</em>&#8221; INDEX, but each document should have a filed named called &#8220;firstName&#8221;</li>
</ul>
<p></p>
<h4><strong>term</strong> Query:</h4>
<p>This query is best when If we know the exact field name and we also want to limit the search result only on documents that have filed value of exactly what we are searching.</p>
<pre class="lang:sh decode:true">GET 192.168.0.1:9200/index_name/_search

{
  "query": {
    "term": {
      "userName": "john"
    }
  }
}</pre>
<p>Note that this query should be perform on Fields within a document that has single term, not on Fields that has many terms inside of it, for example;<br>&#8220;userName&#8221;: &#8220;don john mcalister&#8221;</p>
<p></p>
<h4><strong>match</strong>&nbsp;Query:</h4>
<p>If &#8220;term&#8221; query is not best for search multiple terms, then which query is best of doing the task. This is where match query comes into play which does full-text search at it&#8217;s best.</p>
<pre class="lang:sh decode:true">GET 192.168.0.1:9200/index_name/_search

{
  "query": {
    "match": {
      "userCommnet": "Sri Lanka beautiful country"
    }
  }
}</pre>
<p>Note that even in the actual document&#8217;s &#8220;<strong><em>userComment</em></strong>&#8220;:&nbsp; contains &#8220;<strong><em>Sri Lanka is one of the best beautiful countries in the world</em></strong>&#8221; the above query get you that document out of the result search result.&nbsp;</p>
<p></p>
<h4><strong>query_string</strong>&nbsp;Query:</h4>
<p>If you are looking at AND/OR operators to match document, this would do it for you.</p>
<pre class="lang:sh decode:true">GET 192.168.0.1:9200/index_name/_search

{
  "query": {
    "query_string": {
      "query": "<strong>city</strong>:(new york) OR (new-york)"
    }
  }
}</pre>
<p>Note that <em>&#8220;<strong>city</strong>&#8221; </em>is the field name &amp; rest will be the search text that we are looking..&nbsp;</p>
<p>For basic operations, these type of queries are best for getting task done, but like any other database query, DSL also has many powerful options that leverage to narrow down the search result as to the best of requirement. Once you get these basics covered, you can comment on more for such advanced queries.&nbsp;</p>
<p><em>&#8220;I hope this has been informative for you.&#8221;</em></p>
<p></p>


<p></p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/elasticsearch-dsl-query-examples/">Elasticsearch DSL Query Examples</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/elasticsearch-dsl-query-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
