<?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 Selin Unal on Medium]]></title>
        <description><![CDATA[Stories by Selin Unal on Medium]]></description>
        <link>https://medium.com/@selin.unal?source=rss-ee5beeae0362------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*b8-GhvZMoZ2GWDSt2JHZBg.png</url>
            <title>Stories by Selin Unal on Medium</title>
            <link>https://medium.com/@selin.unal?source=rss-ee5beeae0362------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:39:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@selin.unal/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[Decreasing CI Duration of iOS via Fastlane in Udemy]]></title>
            <link>https://medium.com/udemy-engineering/decreasing-ci-duration-of-ios-via-fastlane-in-udemy-c4f7e7af8e15?source=rss-ee5beeae0362------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4f7e7af8e15</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[fastlane]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Selin Unal]]></dc:creator>
            <pubDate>Fri, 16 Oct 2020 16:21:35 GMT</pubDate>
            <atom:updated>2020-10-16T16:21:35.016Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lM4cd5pZ4o8KQ8wu0uwelA.jpeg" /><figcaption>Photo by Brett Jordan on <a href="https://unsplash.com/s/photos/ios?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The Udemy iOS app gets thousands of users every day. It is so important that we have a testing mechanism and make sure everything works as expected before merging changes to the repository or releasing products to the end-users.</p><p>We have <strong>Unit tests</strong>,<strong> E2E tests,</strong> and <strong>Snapshot tests</strong> in CI for the Udemy iOS app to make sure that it works as expected and does not break any existing features while publishing new changes.</p><h3>In CI</h3><p>We use <a href="https://www.jenkins.io/">Jenkins</a> for continuous integration and <a href="https://fastlane.tools/">Fastlane</a> for automation — i.e. building, testing, and reporting results back to GitHub. Fastlane is a great tool that has lots of <a href="https://github.com/fastlane/fastlane/tree/fd1ff3bf9f46bf1a04e8fd90a826c46899bf845c/fastlane/lib/fastlane/actions">lanes</a> implemented and ready for use. We are using <a href="https://docs.fastlane.tools/actions/scan/">scan</a> lane to take build and run tests in CI. We can give various <a href="https://docs.fastlane.tools/actions/scan/#parameters">parameters</a> to scan to configure it according to our needs. For example, we can specify which project to build, the path of the built product, which tests to execute, or on which device these apps or tests should run.</p><h3>What We Had Before</h3><p>We used to have three schemes and targets for <strong>Unit tests</strong>, <strong>E2E tests,</strong> and <strong>Snapshot tests</strong> in addition to the Udemy iOS app target and scheme. <strong>Xcode target</strong> specifies files, build settings, and build phases to create products. <strong>Xcode scheme </strong>defines a collection of targets, build settings, and a collection of tests that will be executed. The test schemes (Unit, E2E, and Snapshot) have an explicit dependency on the Udemy iOS app which means that before the test target is compiled, the Udemy iOS app needs to be compiled to get the product to be tested. In the picture below, we can summarize the flow for an old configuration of one of the test schemes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HO1trnG7QSRA7vdTsvl5-g.png" /><figcaption>Image by author</figcaption></figure><p>Unit tests, E2E tests, and Snapshot test schemes have the same dependency on the Udemy iOS app. Each scan command compiled the Udemy app target along with its test target since the scheme included both targets and the application was compiled three times from scratch for different test schemes in CI. We can see the summarized way of the usage of the scan lane as below.</p><pre>scan(</pre><pre>workspace: &quot;udemy.xcworkspace&quot;,</pre><pre>device: &quot;iPhone 8&quot;,</pre><pre>scheme: &quot;unit-tests&quot;)<br></pre><pre>scan(</pre><pre>workspace: &quot;udemy.xcworkspace&quot;,</pre><pre>device: &quot;iPhone 8&quot;,</pre><pre>scheme: &quot;snapshot-tests&quot;)<br></pre><pre>scan(</pre><pre>workspace: &quot;udemy.xcworkspace&quot;,</pre><pre>device: &quot;iPhone 8&quot;,</pre><pre>scheme: &quot;e2e-tests&quot;)</pre><h3>What Was the Problem?</h3><p>The job execution was sequential; each test job had to wait for the other jobs to finish. At first, when the number of developers on the team and test counts were low, this wasn’t considered as a blockage in CI. As the team grew, we added more tests which resulted in increased execution time for our jobs and as a result, we ended up blocking our developers for a longer time period.</p><h3>New Configuration</h3><p>We reconfigured the Udemy iOS app scheme and included all of the test targets including Unit tests, E2E tests, and Snapshot test targets which will prevent redundant rebuilds of the app. The new configuration flow becomes something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oxOsg19ohuCbKy1lW_t4VQ.png" /><figcaption>Image by author</figcaption></figure><p>With this new configuration, we build the iOS app only once and the tests are run on this ipa. Scan lane provides awesome parameter options for us to achieve this! Let’s take a look at the parameters that can be used with this new configuration on CI.</p><ul><li><strong>build_for_testing</strong>: Builds for testing only, does not run tests<strong>. </strong>By setting this option to true we say that only compile all of the schemes including app and test targets but do not run tests under this scheme.</li><li><strong>derived_data_path</strong>: Derived data<strong> </strong>location is where all the intermediate and final products of the build process are stored. By default, the derived data path is specified by Xcode uniquely for each project. However, with this option, we can set the derived data path as we want, and all of the compiled files will be stored in this path that we specified.</li><li><strong>test_without_building</strong>: Test without building, requires a derived data path.<strong> </strong>By setting<strong> </strong>this option to true we can use the derived data path that we specify with the build_for_testing option.</li><li><strong>only_testing</strong>: Array of strings matching test bundle/ test-suite/ test cases to run. With this option, we can run tests under specific test targets, for example only unit tests under Unit Test target, at a time.</li></ul><p>Let’s take a look at the new configuration of the scan. Firstly we need to build the Udemy iOS app without running any of the tests. Since the Udemy scheme includes Unit test target, E2E test target, and Snapshot test target all of these targets will be compiled in addition to the Udemy iOS app.</p><pre>scan(</pre><pre>workspace: &quot;udemy.xcworkspace&quot;,</pre><pre>device: &quot;iPhone 8&quot;,</pre><pre>scheme: &quot;udemy&quot;,</pre><pre>build_for_testing: true,</pre><pre>derived_data_path: &quot;/desired-path-for-building/udemy&quot; )</pre><p>Now we can start to use a compiled app and test targets and execute each test one by one.</p><p>To run Unit tests run:</p><pre>scan(</pre><pre>derived_data_path: &quot;/desired-path-for-building/udemy&quot;,</pre><pre>device: &quot;iPhone 8&quot;,</pre><pre>test_without_building: true,</pre><pre>only_testing: &quot;unit-tests&quot;)</pre><p>To run E2E tests run:</p><pre>scan(</pre><pre>derived_data_path: &quot;/desired-path-for-building/udemy&quot;,</pre><pre>device: &quot;iPhone 8&quot;,</pre><pre>test_without_building: true,</pre><pre>only_testing: &quot;e2e-tests&quot;)</pre><p>To run Snapshot tests run:</p><pre>scan(</pre><pre>derived_data_path: &quot;/desired-path-for-building/udemy&quot;,</pre><pre>device: &quot;iPhone 8&quot;,</pre><pre>test_without_building: true,</pre><pre>only_testing: &quot;snapshot-tests&quot;)</pre><h3>What We Gained?</h3><p>That’s all! With this new configuration:</p><ul><li>We no longer make redundant builds of the app for the various test schemes.</li><li>It saves us two build times of the app.</li><li>With this approach, we can save approximately 20 minutes for each test cycle.</li></ul><p>That’s an awesome improvement! With Fastlane and scan, you can improve your mobile CI execution, too!</p><p>Thanks for reading, happy testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4f7e7af8e15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/udemy-engineering/decreasing-ci-duration-of-ios-via-fastlane-in-udemy-c4f7e7af8e15">Decreasing CI Duration of iOS via Fastlane in Udemy</a> was originally published in <a href="https://medium.com/udemy-engineering">Udemy Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Search Query Types in Elasticsearch]]></title>
            <link>https://medium.com/@selin.unal/basic-search-query-types-in-elasticsearch-31474872b8e7?source=rss-ee5beeae0362------2</link>
            <guid isPermaLink="false">https://medium.com/p/31474872b8e7</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[search]]></category>
            <category><![CDATA[querydsl]]></category>
            <category><![CDATA[query]]></category>
            <dc:creator><![CDATA[Selin Unal]]></dc:creator>
            <pubDate>Sun, 03 Nov 2019 17:24:18 GMT</pubDate>
            <atom:updated>2019-11-03T17:24:18.498Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi everyone 👋</p><p>In this post, we will try to understand and explore useful elastic search queries that will help us while using Elasticsearch. In my first Elastic search post, we talked about its basics and how to use kibana and elasticsearch docker containers while learning Elasticsearch which can be found from here:</p><p><a href="https://medium.com/@selin.unal/using-elasticsearch-and-kibana-containers-while-learning-elasticsearch-5f3764798c62">Using Elasticsearch and Kibana containers while learning Elasticsearch</a></p><p>Let’s start to explore search query types. First of all, we need to run elasticsearch and kibana containers. If you have already installed elasticsearch and kibana into your local device, you can use them instead of docker containers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YFYf9pfmjt-LeoY5FPDjOw.png" /><figcaption>Search path of the Elasticsearch</figcaption></figure><p>For this post, we will create a <strong>‘companies’ </strong>index with <strong>‘company’</strong> document type and we will write search queries and search for a company. I want to show you a company document in detail. A company document will contain the following fields:</p><ul><li><strong><em>name</em></strong>: Name of the company</li><li><strong><em>found_year</em></strong>: Foundation year of the company</li><li><strong><em>avg_salary</em></strong>: Average salary of the company</li><li><strong><em>benefits</em></strong>: Benefits of the company that it provides to its employees</li><li><strong><em>num_emp</em></strong>: Total number of employees in the company</li><li><strong><em>city</em></strong>: The city that the company is located</li><li><strong><em>country</em></strong>: The country that the company is located</li></ul><p>Using these values we will create search queries and see which companies are listed by Elasticsearch as a result.</p><p>Let’s create companies index. From the kibana, (for me it is running on <a href="http://localhost:5601/app/kibana">http://localhost:5601/app/kibana</a>) select <strong>‘Dev Tools’</strong> from the left menu and in the console type:</p><pre>PUT /companies/company</pre><pre>{ &quot;settings&quot;: { &quot;number_of_shards&quot;: 1 }}</pre><p>This will create <strong>‘companies’</strong> index with<strong> ‘company’ </strong>document type stored in 1 shard. You can check whether your index is created successfully or not from the coming message from the Elasticsearch. You need to see:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50f2b07704653714fd903b114849204f/href">https://medium.com/media/50f2b07704653714fd903b114849204f/href</a></iframe><p>You can check whether this index is created or not by executing this command:</p><pre>GET _cat/indices</pre><p>You need to see companies index in the response listed in the screen:</p><pre>yellow open companies            IpVICcPZTtSDxls6dRmX8g 1 1      5 0   12kb   12kb</pre><p>Now, we will insert our company documents into the <strong>‘companies’</strong> index. For this post, we have 5 documents. We will insert documents by using bulk insert property, that is when we have lots of documents with bulk insert we can add documents easily. Just copy the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bcf2f5529ad9c817244baccf4d350c3/href">https://medium.com/media/8bcf2f5529ad9c817244baccf4d350c3/href</a></iframe><p>We have 5 companies in total with type <strong>‘company’ </strong>under the index <strong>‘companies’</strong>.</p><p>You can see all your company documents by typing:</p><pre>GET /companies/company/_search</pre><pre>{&quot;query&quot;: {&quot;match_all&quot;: {}}}</pre><p>You will see:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ad86a13005aa37f2dfd7ac4fb60c821/href">https://medium.com/media/4ad86a13005aa37f2dfd7ac4fb60c821/href</a></iframe><p>_index,_type, _id, _score, _source fields are metadata fields that are held by Elasticsearch. Under the _source field, we can see all of the company information that we inserted before.</p><p>Now we can start to search elastically!</p><p>There are two types of searching methods in Elasticsearch. One is <strong>Search Lite API</strong> which expects search parameters in URL, the other one is <strong>Elasticsearch Query DSL</strong> (Domain Specific Language) that based on JSON to define queries. We will use Query DSL for this post.</p><p>In the following sections, we will cover useful search query types one by one. We will cover basic match query, bool query, fuzzy query, wildcard and regexp queries, match phrase query, term and terms queries and finally range queries.</p><h4>Basic Match Query</h4><p>This query allows us to search a word in a specified field or in all of the fields. For example, if we want to search <em>‘Web Technology’</em> in the name field we need to execute:</p><pre>GET /companies/company/_search<br>{<br>  &quot;query&quot;: {&quot;match&quot;: {<br>    &quot;name&quot;: &quot;Web Technology&quot;}},<br>  &quot;_source&quot;: [&quot;name&quot;, &quot;brief_info&quot;]<br>}</pre><p>We will see:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebcde86c880fd32794a5c3fdd03169c5/href">https://medium.com/media/ebcde86c880fd32794a5c3fdd03169c5/href</a></iframe><p>‘Web’ and ‘Technology’ words are searched in all of the documents’ name field and a match occurs that document is added to the result documents. Additionally, we restrict the result fields by specifying “_source” field in the query.</p><p><strong>‘Match’ </strong>query is used for searching the word in the specified field. If a match occurs in the field that document is returned back to the user.</p><p>If we want to search a word in more than one field we use <strong>‘multi_match’</strong> query which allows searching the word in multiple fields. For example, when we want to search the companies with ‘sport discount’ benefit and in ‘San Francisco’ city, we execute the following command:</p><pre>GET /companies/company/_search<br>{<br>  &quot;query&quot;: {<br>    &quot;multi_match&quot;: {<br>      &quot;query&quot;: &quot;San Francisco sport&quot;,<br>      &quot;fields&quot;: [&quot;city&quot;, &quot;benefits&quot;]<br>    }<br>  },<br>  &quot;_source&quot;: [&quot;city&quot;, &quot;benefits&quot;]<br>}</pre><p>This query will search San Francisco and sport words in the fields <strong>‘city’ </strong>and <strong>‘benefits’</strong>. Whenever a match occurs, that document will be added to the result. Therefore we will see:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18d30dbee22450e9a67b79bbb39cfb13/href">https://medium.com/media/18d30dbee22450e9a67b79bbb39cfb13/href</a></iframe><p>If we do not specify the fields in the multi_match query, the desired word will be searched in all of the fields. At the beginning of the indexing, Elasticsearch holds all of the fields under the <strong>_all</strong> field. <strong>_all </strong>field is created by concatenating all of the source fields of the document. And Elasticsearch can search the desired word by looking at this <strong>_all</strong> field. For example, let’s search <strong>‘web technology’ </strong>in all fields by using multi_match query type.</p><pre>GET /companies/company/_search<br>{<br>  &quot;query&quot;: {<br>    &quot;multi_match&quot;: {<br>      &quot;query&quot;: &quot;web technology&quot;<br>    }<br>  }<br>}</pre><p>This query will return the documents that have ‘web’ or ‘technology’ words in any of the fields. We will see:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26957417082048e18007b841399bc847/href">https://medium.com/media/26957417082048e18007b841399bc847/href</a></iframe><h4>Bool Query</h4><p>Bool queries are used to write queries with AND/OR/NOT operators.</p><p>In Elasticsearch Query DSL: ‘must’ means AND, ‘should’ means OR and ‘must_not’ means NOT.</p><p>For example, if we want to search for companies with benefits ‘sports’ OR ‘rented-house’ and NOT in the cities ‘Ankara’ AND ‘Amsterdam’ we execute the following query:</p><pre>GET /companies/company/_search <br>{<br>  &quot;query&quot;: {<br>    &quot;bool&quot;: {<br>      &quot;must&quot;: [<br>      {<br>          &quot;bool&quot;: {<br>            &quot;should&quot;: [<br>              {<br>                &quot;match&quot;: {<br>                  &quot;benefits&quot;: &quot;sport&quot;<br>                }<br>              },<br>              {<br>                &quot;match&quot;: {<br>                  &quot;benefits&quot;: &quot;rented house&quot;<br>                }<br>              }<br>            ]<br>          }<br>        }<br>     ],<br>      &quot;must_not&quot;: [<br>        {<br>          &quot;bool&quot;: {<br>            <br>            &quot;should&quot;: [<br>              {<br>                &quot;match&quot;: {<br>                  &quot;city&quot;: &quot;Ankara&quot;<br>                }<br>              },<br>              {<br>                &quot;match&quot;: {<br>                  &quot;city&quot;: &quot;Amsterdam&quot;<br>                }<br>              }<br>            ]<br>          }<br>        }<br>      ]<br>    }<br>  }<br>}</pre><p>And we will see the following response:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9b1df6691e4745f24fad1fae0781a5f/href">https://medium.com/media/d9b1df6691e4745f24fad1fae0781a5f/href</a></iframe><h4>Fuzzy Queries</h4><p>When searching with match and multi_match queries fuzzy matching can be enabled for the phrases that are spelled incorrectly. For example, when we type ‘<strong>developmnt</strong>’ instead of ‘<strong>development’</strong> with fuzzy queries, results still can be found. In the search query, we need to specify fuzziness value that means how many characters of typos we will allow. If we write 1, it means only 1 character mismatch is allowed, if we type 2, 2 character mismatch is allowed. When we select AUTO, according to word length, distance is calculated accordingly.</p><p>Lets search with a fuzzy query:</p><pre>GET /companies/company/_search<br>{<br>    &quot;query&quot;: {<br>        &quot;multi_match&quot; : {<br>            &quot;query&quot; : &quot;developmnt&quot;,<br>            &quot;fields&quot;: [&quot;name&quot;, &quot;brief_info&quot;],<br>            &quot;fuzziness&quot;: &quot;AUTO&quot;<br>        }<br>    },<br>    &quot;_source&quot;: [&quot;brief_info&quot;, &quot;name&quot;]<br>}</pre><p>This query will search misspelled word in the fields name and brief_info. With specifying fuzziness value to AUTO it will find <strong>‘development’</strong> and match. Result documents will be the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0ea174a1a3684d60d58ea1e2696c752/href">https://medium.com/media/c0ea174a1a3684d60d58ea1e2696c752/href</a></iframe><h4>Wildcard and Regexp Queries</h4><p>Wildcard queries allow us to search a matching phrase pattern instead of searching full phrases. In wildcard query <strong>? </strong>matches any character, <strong>*</strong> matches zero or more characters.</p><p>For example, if we want to search <strong>developm* </strong>in the brief_info field<strong> </strong>, we can execute the following query:</p><pre>GET  /companies/company/_search<br>{<br>    &quot;query&quot;: {<br>        &quot;wildcard&quot; : {<br>            &quot;brief_info&quot;: &quot;developm*&quot;<br>        }<br>    },<br>    &quot;_source&quot;: [&quot;name&quot;, &quot;brief_info&quot;],<br>    &quot;highlight&quot;: {<br>        &quot;fields&quot; : {<br>            &quot;brief_info&quot;: {}<br>        }<br>    }<br>}</pre><p>This query will match any document that has ‘<strong>developm*</strong>’ in its brief_info filed. Since <strong>‘development’ </strong>word fits the phrase we will see following result:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8594e661ed74f40411e75dc363becd55/href">https://medium.com/media/8594e661ed74f40411e75dc363becd55/href</a></iframe><p>Like wildcard queries, regexp queries also used to search for a pattern that is more complex than wildcard queries. For example, when we want to search the companies in the cities that ends with <strong>‘m’ </strong>we execute<strong>:</strong></p><pre>GET /companies/company/_search<br>{<br>    &quot;query&quot;: {<br>        &quot;regexp&quot; : {<br>            &quot;city&quot; : &quot;[a-z]*m&quot;<br>        }<br>    },<br>    &quot;_source&quot;: [&quot;name&quot;, &quot;city&quot;],<br>    &quot;highlight&quot;: {<br>        &quot;fields&quot; : {<br>            &quot;city&quot; : {}<br>        }<br>    }<br>}</pre><p>And we see the result:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d244afb83e8cb97544485d92f4c6ef8c/href">https://medium.com/media/d244afb83e8cb97544485d92f4c6ef8c/href</a></iframe><h4>Match Phrase Query</h4><p>Match phrase query requires the searched phrase to occur in the same order in the searched field, close to each other. For example, if we search <strong>‘web development’</strong> in the <strong>brief_info </strong>field we say that <strong>‘web technology’ </strong>has to<strong> </strong>occur exactly in the same order in this field. Let’s show this with an example match phrase query:</p><pre>GET /companies/company/_search <br>{<br>  &quot;query&quot;: {<br>    &quot;match_phrase&quot;: {<br>      &quot;brief_info&quot;:&quot;web technology&quot;<br>      }<br>  },<br>    &quot;_source&quot;: [&quot;name&quot;, &quot;brief_info&quot;],<br>    &quot;highlight&quot;: {<br>        &quot;fields&quot; : {<br>            &quot;brief_info&quot;: {}<br>        }<br>    }<br>}</pre><p>We will see :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66b93aa7ee7f12e1f83ffecdaf26fda2/href">https://medium.com/media/66b93aa7ee7f12e1f83ffecdaf26fda2/href</a></iframe><p>If we type ‘technology web’ results will return empty like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1d76ce9a55a8be0bb574549bc4d8af5/href">https://medium.com/media/e1d76ce9a55a8be0bb574549bc4d8af5/href</a></iframe><h4>Term and Terms Query</h4><p>Term and terms queries are used to search for exact match in the field. If we want to search for companies that have exact employee number 500, we can use term query like below:</p><pre>GET /companies/company/_search<br>{<br>    &quot;query&quot;: {<br>      &quot;term&quot;: {<br>        &quot;num_emp&quot;: {<br>          &quot;value&quot;: &quot;500&quot;<br>        }<br>      }<br>    },<br>    &quot;_source&quot;: [&quot;name&quot;, &quot;num_emp&quot;]<br>}</pre><p>Then we will see in the results:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efe5f0d57b3b26b64b38379c6b76c4c0/href">https://medium.com/media/efe5f0d57b3b26b64b38379c6b76c4c0/href</a></iframe><h4>Range Query</h4><p>Range queries allow us to search for values between the desired range. For example, we can search the companies that are founded after <strong>2010</strong> and before <strong>2015</strong> by executing the following query:</p><pre>GET /companies/company/_search<br>{<br>    &quot;query&quot;: {<br>        &quot;range&quot; : {<br>            &quot;found_year&quot;: {<br>                &quot;gte&quot;: &quot;2010-01-01&quot;,<br>                &quot;lte&quot;: &quot;2015-12-31&quot;<br>            }<br>        }<br>    },<br>    &quot;_source&quot; : [&quot;name&quot;,&quot;found_year&quot;]<br>}</pre><p>Then we will see the companies:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ebe41e751adc175169a303a694c252c/href">https://medium.com/media/6ebe41e751adc175169a303a694c252c/href</a></iframe><p>As we can see from the basic Elasticsearch query examples, we can search in a lot of different ways and in a very practical manner. Thank you for reading.</p><p>Happy searching 💚</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31474872b8e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Elasticsearch and Kibana containers while learning Elasticsearch]]></title>
            <link>https://medium.com/@selin.unal/using-elasticsearch-and-kibana-containers-while-learning-elasticsearch-5f3764798c62?source=rss-ee5beeae0362------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f3764798c62</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[kibana]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Selin Unal]]></dc:creator>
            <pubDate>Sun, 20 Oct 2019 18:42:46 GMT</pubDate>
            <atom:updated>2019-11-02T19:51:31.093Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey all, I wanted to learn Elasticsearch and found a course on Udemy, named Elasticsearch 7 and the Elastic Stack — In-Depth &amp; Hands-On! It was a very informative course for me. I have learned Elasticsearch basics and have lots of ideas about its working flow and want to share these with you!</p><p>First things first, let me explain very basic concepts of Elasticsearch. Elasticsearch is a searching tool. It contains clusters, indexes, and documents. If you are familiar with RDBMS concepts, we can make an analogy with Elasticsearch concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*lJqoWu7yuzXrawTDdnJBLw.png" /><figcaption><strong>Elasticsearch-SQL analogy</strong></figcaption></figure><p>Lets briefly describe each of the main components of Elasticsearch. A field can be thought a data storage unit. For example, let’s say we have a person entity and each person has a name, surname, age, and country. For this example name, surname, age, and country will be the <strong>fields </strong>of the person entity. The person itself will be our <strong>document</strong> in Elasticsearch. People will be our <strong>index</strong> that consists of documents of person. Let’s visualize this.</p><figure><img alt="An example cluster with index, document and fields" src="https://cdn-images-1.medium.com/max/488/1*2nG0lTisiHLCSs5Mo754ww.png" /><figcaption><strong>An example cluster with fields, document, and index</strong></figcaption></figure><p>After learning basic components of Elasticsearch, it is worth saying we can communicate with Elasticsearch by using Restful API calls. In the course, the instructor used curl command-line tool to talk Elasticsearch. We need to install Elasticsearch on our local computers. Instead of this, since containers are more handy for me, we will use Elasticsearch and Kibana containers to try basic Elasticsearch commands and see their results using Kibana.</p><p>In order to create our very first index in Elasticsearch, we need to download Elasticsearch and Kibana images. For this post, you need to have installed docker. If not, you can set it for mac from here: <a href="https://docs.docker.com/docker-for-mac/install/">https://docs.docker.com/docker-for-mac/install/</a>, for windows from here: <a href="https://docs.docker.com/docker-for-windows/install/">https://docs.docker.com/docker-for-windows/install/</a>.</p><p>Run this command to pull Elasticsearch image with 6.7.1 tag. If you want to you can download another Elasticsearch image with the desired tag. You can check existing Elasticsearch images from here: <a href="https://hub.docker.com/_/elasticsearch">https://hub.docker.com/_/elasticsearch</a>.</p><pre>docker pull elasticsearch:6.7.1</pre><p>Run this command to pull Kiabana image with 6.7.1 tag. Again if you want to you can pull another Kibana image with the desired tag. You can check existing Kibana images from the link: <a href="https://hub.docker.com/_/kibana">https://hub.docker.com/_/kibana</a>.</p><pre>docker pull kibana:6.7.1</pre><p>After pulling these images, now we can run our containers. Before doing this we need to create a docker network to make Kibana and Elasticsearch communicable. Elasticsearch’s default port is 9200, and Kibana’s default port is 5601. After noting these ports, let&#39;s run following commands from the terminal.</p><pre>docker network create networkForEs</pre><pre>docker run -d --name elasticsearch --net networkForEs -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” elasticsearch:6.7.1</pre><pre>docker run -d --name kibana --net networkForEs -p 5601:5601 kibana:6.7.1</pre><p>Open localhost:9200 and you will see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*rDWWTnkawr2ceO49O_1X9g.png" /><figcaption><strong>Successful Elasticsearch response</strong></figcaption></figure><p>Open localhost:5601 and you will see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tWtqugJF9foqgk0GLNGhw.png" /><figcaption><strong>Successful Kibana response</strong></figcaption></figure><p>As we see our containers up and running. They are ready to be used!</p><p>Go to Kibana and select <em>Dev Tools</em> from the left menu. This will open a console to you and we can start to create our very first index by typing:</p><pre>PUT people</pre><p>And we receive a JSON response like this:</p><pre>{ “acknowledged” : true, “shards_acknowledged” : true,“index” : “people”}</pre><p>Check your index is there:</p><pre>GET _cat/indices</pre><p>You see:</p><pre>yellow open people</pre><p>And put a person document to the people index that we create:</p><pre>POST people/_doc { “name”: “John”, “surname”: “Doe”, “age”: 23, “country” :“England”}</pre><p>You will receive a JSON response like this:</p><pre>{“_index” : “people”, “_type” : “_doc”, “_id” : “zSw-6m0B_6iqInRoJNdm”, “_version” : 1, “result” : “created”, “_shards” : {“total” : 2,“successful” : 1,“failed” : 0}, “_seq_no” : 0, “_primary_term” : 1}</pre><p>You can check your document is there:</p><pre>GET people/_search {“query”: {“match_all”: {}} }</pre><p>And you will see:</p><pre>{ “took” : 7, “timed_out” : false, “_shards” : { “total” : 5, “successful” : 5, “skipped” : 0, “failed” : 0}, “hits” : { “total” : 1, “max_score” : 1.0, “hits” : [ {“_index” : “people”, “_type” : “_doc”, “_id” : “zSw-6m0B_6iqInRoJNdm”, “_score” : 1.0, “_source” : { “name” : “John”, “surname” : “Doe”, “age” : 23, “country” : “England” } } ] } }</pre><p>That&#39;s all! Now you can use Elasticsearch and Kibana containers for your Elasticsearch learning steps. After you are done do not forget removing your containers by using the following commands:</p><pre>docker container rm -f elasticsearch</pre><pre>docker container rm -f kibana</pre><p>Happy learning 🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f3764798c62" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>