<?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>Elastic Search - Moses Dinakaran</title>
	<atom:link href="https://mosesdinakaran.in/category/tutorials/elastic-search/feed/" rel="self" type="application/rss+xml" />
	<link>https://mosesdinakaran.in</link>
	<description>Tutorials and Documentations on Magento</description>
	<lastBuildDate>Mon, 18 Sep 2023 13:57:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>How to Enable &#039;eq&#039; Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</title>
		<link>https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2</link>
					<comments>https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/#respond</comments>
		
		<dc:creator><![CDATA[mosesdinakaran@gmail.com]]></dc:creator>
		<pubDate>Mon, 18 Sep 2023 13:57:13 +0000</pubDate>
				<category><![CDATA[Elastic Search]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://mosesdinakaran.in/?p=2394</guid>

					<description><![CDATA[<p>Generally there are 3 types of filter that you can use with graphql search and these filter type depends upon your attribute configuration. FilterEqualTypeInput&#160;- Input type is set to Yes/No, Select, or Multiple select. Your filter can contain the&#160;eq&#160;or&#160;in&#160;attribute. Use the&#160;eq&#160;attribute to exactly match the specified string. Use the&#160;in&#160;attribute to filter on a comma-separated list [&#8230;]</p>
<p>The post <a href="https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/">How to Enable 'eq' Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Generally there are 3 types of filter that you can use with graphql search and these filter type depends upon your attribute configuration.</p>



<ul class="wp-block-list"><li><code>FilterEqualTypeInput</code>&nbsp;- Input type  is set to Yes/No, Select, or Multiple select. Your filter can contain the&nbsp;<code>eq</code>&nbsp;or&nbsp;<code>in</code>&nbsp;attribute. Use the&nbsp;<code>eq</code>&nbsp;attribute to exactly match the specified string. Use the&nbsp;<code>in</code>&nbsp;attribute to filter on a comma-separated list of values.</li><li><code>FilterMatchTypeInput</code>&nbsp;- Input type is set to Text Field or Text Area. Your filter must contain the&nbsp;<code>match</code>&nbsp;attribute, which will return all items that partially fuzzy match the specified string.</li><li><code>FilterRangeTypeInput</code>&nbsp;- Input type  is set to Price or Date. Your filter can contain one or both of the&nbsp;<code>to</code>&nbsp;and&nbsp;<code>from</code>&nbsp;attributes, which serve to provide a range of values to filter on.</li></ul>



<p>If, for any reason, you require the text attribute to support the "eq" filter, you can follow the steps below:</p>



<p>Text attributes are using <code>match</code> attributes OOTB. But Magento leaves open door to change this behavior by injecting the custom attribute using the below classes. This behaviour we can see for <code>sku</code>,url_key  etc.</p>



<ul class="wp-block-list"><li><code>Magento\CatalogGraphQl\Model\Config\FilterAttributeReader</code> - inject <code>style_code</code> to <code>private $exactMatchAttributes = ['sku'];</code> allows to change graphQL queries to use <code>eq</code> attribute</li><li><code>Magento\CatalogGraphQl\Plugin\Search\Request\ConfigReader</code> - inject <code>style_code</code> to “exactMatchAttribute“ change request guery for Elasticsearch.</li></ul>



<h5 class="wp-block-heading">Changel Graphql query to use eq filter</h5>



<p>Update the di.xml file to inject the custom attribute  to the variable exactMatchAttributes to the class Magento\CatalogGraphQl\Model\Config\FilterAttributeReader</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;type name=&quot;Magento\CatalogGraphQl\Model\Config\FilterAttributeReader&quot;&gt;
    &lt;arguments&gt;
        &lt;argument name=&quot;exactMatchAttributes&quot; xsi:type=&quot;array&quot;&gt;
            &lt;item name=&quot;custom_attribute&quot; xsi:type=&quot;string&quot;&gt;style_code&lt;/item&gt;
        &lt;/argument&gt;
    &lt;/arguments&gt;
&lt;/type&gt;
</pre></div>


<h5 class="wp-block-heading">
Change request query for Elasticsearch
</h5>



<p> Update the di.xml file to inject the custom attribute  to the variable exactMatchAttributes in the class Magento\CatalogGraphQl\Plugin\Search\Request\ConfigReader</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&amp;lt;type name=&quot;Magento\CatalogGraphQl\Plugin\Search\Request\ConfigReader&quot;&gt;
    &amp;lt;arguments&gt;
         &amp;lt;argument name=&quot;exactMatchAttributes&quot; xsi:type=&quot;array&quot;&gt;
                &amp;lt;item name=&quot;style_code&quot; xsi:type=&quot;string&quot;&gt;style_code&amp;lt;/item&gt;
         &amp;lt;/argument&gt;
    &amp;lt;/arguments&gt;
&amp;lt;/type&gt;
</pre></div>


<p></p>



<h5 class="wp-block-heading">Verify Elasticsearch Keyword mapping</h5>



<p>If an attribute needs to be searched with eq filter the attribute should have the keyword index mapping in the ElasticSearch.</p>



<p>This can be vieified iwth the below curl comand</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; highlight: [11]; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_mapping/field/url_key&#039;
{
  &quot;mappings&quot;: {
    &quot;url_key&quot;: {
      &quot;full_name&quot;: &quot;url_key&quot;,
      &quot;mapping&quot;: {
        &quot;url_key&quot;: {
          &quot;type&quot;: &quot;text&quot;,
          &quot;fields&quot;: {
            &quot;keyword&quot;: {
              &quot;type&quot;: &quot;keyword&quot;
            }
          },
          &quot;copy_to&quot;: &#x5B;
            &quot;_search&quot;
          ]
        }
      }
    }
  }
}
</pre></div>


<p></p>



<p>Generally for all the attributes where the backend_type is "text", The keword mapping would not be set by default.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="98" src="https://mosesdinakaran.in/wp-content/uploads/2023/09/image-1024x98.png" alt="" class="wp-image-2398" srcset="https://mosesdinakaran.in/wp-content/uploads/2023/09/image-1024x98.png 1024w, https://mosesdinakaran.in/wp-content/uploads/2023/09/image-300x29.png 300w, https://mosesdinakaran.in/wp-content/uploads/2023/09/image-768x74.png 768w, https://mosesdinakaran.in/wp-content/uploads/2023/09/image-1536x148.png 1536w, https://mosesdinakaran.in/wp-content/uploads/2023/09/image.png 1581w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Here the attribute "test_text" will not have a keword mapping in elasticsearch so we cannot use "eq" filter.</p>



<p>To know more preciesly on where keword mapping will not be added refer the below file.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField::getField
</pre></div>


<p></p>



<p>But you can still make this type of attribute to support keyword mapping by updating the attribute index mapping. The index mapping for an attribute this set in the below method. So we can crete the afterPlugin for this method and have the mapping updated.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField::getFields
</pre></div><p>The post <a href="https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/">How to Enable 'eq' Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Magento 2 - Useful Elasticsearch Commands</title>
		<link>https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=magento-2-useful-elasticsearch-commands</link>
					<comments>https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/#respond</comments>
		
		<dc:creator><![CDATA[mosesdinakaran@gmail.com]]></dc:creator>
		<pubDate>Thu, 20 Oct 2022 08:33:38 +0000</pubDate>
				<category><![CDATA[Elastic Search]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://mosesdinakaran.in/?p=1445</guid>

					<description><![CDATA[<p>In this document, we will cover the elastic search commands that we generally used in the context of Magento debugging. Related Tutorials To get the Indices Details List all indices Sample Output List all aliases Delete All Indices Sample Output To Fetch the Data directly from Elasticsearch Get Records Count To fetch the total no [&#8230;]</p>
<p>The post <a href="https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/">Magento 2 - Useful Elasticsearch Commands</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>In this document, we will cover the elastic search commands that we generally used in the context of Magento debugging.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%"></div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<p><strong>Related Tutorials</strong></p>



<ul class="lcp_catlist" id="lcp_instance_0"><li><a href="https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/" class="lcp_title_maroon">How to Enable 'eq' Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</a></li><li class="current"><a href="https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/" class="lcp_title_maroon">Magento 2 - Useful Elasticsearch Commands</a></li><li><a href="https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/" class="lcp_title_maroon">Magento 2 - Elastic Search Concepts for a Magento Developer</a></li><li><a href="https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/" class="lcp_title_maroon">Magento 2 - How data is fetched from Elasticserach</a></li><li><a href="https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/" class="lcp_title_maroon">How Product Data is Pushed to Elasticsearch from Magento</a></li><li><a href="https://mosesdinakaran.in/elastic-search-for-magento-developer/" class="lcp_title_maroon">Elastic Search for Magento Developer</a></li></ul>
</div>
</div>



<p></p>



<h3 class="wp-block-heading">To get the  Indices Details</h3>



<h6 class="wp-block-heading">List all indices </h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/_cat/indices?v&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; gutter: false; title: ; notranslate">
health status index                   uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   magento2_product_14_v18 WfscY4ghRRCJXCwQnXfqiA   1   1          7            0     17.3kb         17.3kb
yellow open   magento2_product_38_v18 zk6DJO9YRHaeGxk5XLKQOA   1   1         20            0     46.9kb         46.9kb
</pre></div>


<h6 class="wp-block-heading">List all aliases</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/_cat/aliases/?v&#039;
</pre></div>


<h6 class="wp-block-heading">Delete All Indices</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
curl -X DELETE &quot;localhost:9200/*?pretty&quot;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
alias               index                   filter routing.index routing.search is_write_index
magento2_product_27 magento2_product_27_v18 -      -             -              -
commerce_product_7  commerce_product_7_v9   -      -             -              -
</pre></div>


<h3 class="wp-block-heading">To Fetch the Data directly from Elasticsearch</h3>



<h6 class="wp-block-heading">Get Records Count</h6>



<p>To fetch the total no of records in the indices, Replace * with index name to get the total no of records for a specific index</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_count&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
{
    &quot;count&quot;: 33,
    &quot;_shards&quot;: {
        &quot;total&quot;: 1,
        &quot;successful&quot;: 1,
        &quot;skipped&quot;: 0,
        &quot;failed&quot;: 0
    }
}
</pre></div>


<h6 class="wp-block-heading">Get all the Records</h6>



<p>To fetch all the records from all the indices, replace * with the index name to fetch all the records of a specific index</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_search&#039; \
--header &#039;Content-Type: application/json&#039; \
--data-raw &#039;{
   &quot;track_total_hits&quot; : true
}&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
{
    &quot;took&quot;: 13,
    &quot;timed_out&quot;: false,
    &quot;_shards&quot;: {
        &quot;total&quot;: 1,
        &quot;successful&quot;: 1,
        &quot;skipped&quot;: 0,
        &quot;failed&quot;: 0
    },
    &quot;hits&quot;: {
        &quot;total&quot;: {
            &quot;value&quot;: 33,
            &quot;relation&quot;: &quot;eq&quot;
        },
        &quot;max_score&quot;: 1.0,
        &quot;hits&quot;: &#x5B;
            {
                &quot;_index&quot;: &quot;magento2_product_1_v26&quot;,
                &quot;_type&quot;: &quot;document&quot;,
                &quot;_id&quot;: &quot;340&quot;,
                &quot;_score&quot;: 1.0,
                &quot;_source&quot;: {
                    &quot;store_id&quot;: &quot;1&quot;,
                    &quot;sku&quot;: &quot;0986361001&quot;,
                    &quot;updated_at&quot;: &quot;2022-09-30T07:13:01+00:00&quot;,
                    &quot;status&quot;: 1,
				}
            },
			{
                &quot;_index&quot;: &quot;magento2_product_1_v26&quot;,
                &quot;_type&quot;: &quot;document&quot;,
                &quot;_id&quot;: &quot;1714&quot;,
                &quot;_score&quot;: 1.0,
                &quot;_source&quot;: {
                    &quot;store_id&quot;: &quot;1&quot;,
                    &quot;sku&quot;: &quot;KKALSHAYA-001&quot;,
                    &quot;updated_at&quot;: &quot;2022-06-01T06:29:42+00:00&quot;,
                    &quot;status&quot;: 1,
				}
			}
        ]
    }
}
</pre></div>


<h6 class="wp-block-heading">Get all the Records with limit</h6>



<p>To fetch from a specific index, replace * with the index name</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_search&#039; \
--header &#039;Content-Type: application/json&#039; \
--data-raw &#039;{
  &quot;query&quot;: {
    &quot;match_all&quot;: {}
  },
  &quot;_source&quot;: &#x5B;&quot;sku&quot;],
  &quot;from&quot; : 1,
  &quot;size&quot; : 3
}&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
{
    &quot;took&quot;: 20,
    &quot;timed_out&quot;: false,
    &quot;_shards&quot;: {
        &quot;total&quot;: 20,
        &quot;successful&quot;: 20,
        &quot;skipped&quot;: 0,
        &quot;failed&quot;: 0
    },
    &quot;hits&quot;: {
        &quot;total&quot;: {
            &quot;value&quot;: 207,
            &quot;relation&quot;: &quot;eq&quot;
        },
        &quot;max_score&quot;: 1.0,
        &quot;hits&quot;: &#x5B;
            {
                &quot;_index&quot;: &quot;commerce_product_1_v9&quot;,
                &quot;_type&quot;: &quot;document&quot;,
                &quot;_id&quot;: &quot;2&quot;,
                &quot;_score&quot;: 1.0,
                &quot;_source&quot;: {
                    &quot;sku&quot;: &quot;24-MB04&quot;
                }
            },
            {
                &quot;_index&quot;: &quot;commerce_product_1_v9&quot;,
                &quot;_type&quot;: &quot;document&quot;,
                &quot;_id&quot;: &quot;3&quot;,
                &quot;_score&quot;: 1.0,
                &quot;_source&quot;: {
                    &quot;sku&quot;: &quot;24-MB03&quot;
                }
            },
            {
                &quot;_index&quot;: &quot;commerce_product_1_v9&quot;,
                &quot;_type&quot;: &quot;document&quot;,
                &quot;_id&quot;: &quot;430&quot;,
                &quot;_score&quot;: 1.0,
                &quot;_source&quot;: {
                    &quot;sku&quot;: &quot;MJ12&quot;
                }
            }
        ]
    }
}
</pre></div>


<p><strong>To get a specific document</strong></p>



<p>You should know the document ID. Here 1726 is the document id and magento2_product_1_v26 is the index name</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/magento2_product_1_v26/_doc/1726&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
{
    &quot;_index&quot;: &quot;magento2_product_1_v26&quot;,
    &quot;_type&quot;: &quot;_doc&quot;,
    &quot;_id&quot;: &quot;1726&quot;,
    &quot;_version&quot;: 1,
    &quot;_seq_no&quot;: 5,
    &quot;_primary_term&quot;: 1,
    &quot;found&quot;: true,
    &quot;_source&quot;: {
        &quot;store_id&quot;: &quot;1&quot;,
        &quot;sku&quot;: &quot;giftcard_topup&quot;,
        &quot;updated_at&quot;: &quot;2022-05-06T11:23:10+00:00&quot;,
        &quot;status&quot;: 1,
        &quot;status_value&quot;: &quot;Enabled&quot;,
        &quot;visibility&quot;: 4,
        &quot;ship_to_store&quot;: 1,
        &quot;ship_to_store_value&quot;: &quot;Enabled&quot;,
        &quot;reserve_and_collect&quot;: 1,
        &quot;reserve_and_collect_value&quot;: &quot;Enabled&quot;,
        &quot;is_buyable&quot;: 1,
        &quot;tax_class_id&quot;: 0,
        &quot;tax_class_id_value&quot;: &quot;None&quot;,
        &quot;is_sale&quot;: 0,
        &quot;is_new&quot;: 1,
        &quot;same_day_delivery&quot;: 0,
        &quot;same_day_delivery_value&quot;: &quot;No&quot;,
        &quot;express_delivery&quot;: 0,
        &quot;express_delivery_value&quot;: &quot;No&quot;,
        &quot;name&quot;: &quot;topup&quot;,
        &quot;url_key&quot;: &quot;buy-topup&quot;,
        &quot;product_activation_date&quot;: &quot;2022-03-04T00:00:00+00:00&quot;,
        &quot;category_ids&quot;: &#x5B;
            2,
            3736
        ],
        &quot;position_category_2&quot;: &quot;10003&quot;,
        &quot;name_category_2&quot;: &quot;category1&quot;,
        &quot;position_category_3736&quot;: &quot;3&quot;,
        &quot;name_category_3736&quot;: &quot;HPS Gift Card&quot;,
        &quot;price_0_1&quot;: &quot;10.000000&quot;,
        &quot;price_1_1&quot;: &quot;10.000000&quot;
    }
}
</pre></div>


<p></p>



<h6 class="wp-block-heading">Fetch Data based on SKU</h6>



<p>To fetch from a specific index, replace * with the index name</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_search&#039; \
--header &#039;Content-Type: application/json&#039; \
--data-raw &#039;{
  &quot;query&quot;: {
      &quot;match&quot;: {&quot;sku&quot;: &quot;24-MB04&quot;}
    }, &quot;_source&quot;: &#x5B;&quot;name&quot;,&quot;sku&quot;,&quot;status&quot;,&quot;url_key&quot;,&quot;visibility&quot;,&quot;store_id&quot;,&quot;updated_at&quot;]
}&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
{
    &quot;took&quot;: 7,
    &quot;timed_out&quot;: false,
    &quot;_shards&quot;: {
        &quot;total&quot;: 1,
        &quot;successful&quot;: 1,
        &quot;skipped&quot;: 0,
        &quot;failed&quot;: 0
    },
    &quot;hits&quot;: {
        &quot;total&quot;: {
            &quot;value&quot;: 1,
            &quot;relation&quot;: &quot;eq&quot;
        },
        &quot;max_score&quot;: 1.2039728,
        &quot;hits&quot;: &#x5B;
            {
                &quot;_index&quot;: &quot;commerce_product_1_v9&quot;,
                &quot;_type&quot;: &quot;document&quot;,
                &quot;_id&quot;: &quot;2&quot;,
                &quot;_score&quot;: 1.2039728,
                &quot;_source&quot;: {
                    &quot;store_id&quot;: &quot;1&quot;,
                    &quot;visibility&quot;: 4,
                    &quot;name&quot;: &quot;strive shoulder pack&quot;,
                    &quot;sku&quot;: &quot;24-MB04&quot;,
                    &quot;url_key&quot;: &quot;strive-shoulder-pack&quot;,
                    &quot;status&quot;: 1
                }
            }
        ]
    }
}
</pre></div>


<h3 class="wp-block-heading">Get General Info on Elasticsearch Instance</h3>



<h6 class="wp-block-heading">To Get all the settings for all the indices.</h6>



<p>Replace * with the index name to get the setting for a specific index.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_settings&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
{
    &quot;magento2_product_41_v18&quot;: {
        &quot;settings&quot;: {
            &quot;index&quot;: {
                &quot;routing&quot;: {
                    &quot;allocation&quot;: {
                        &quot;include&quot;: {
                            &quot;_tier_preference&quot;: &quot;data_content&quot;
                        }
                    }
                },
                &quot;mapping&quot;: {
                    &quot;total_fields&quot;: {
                        &quot;limit&quot;: &quot;101938&quot;
                    }
                },
                &quot;number_of_shards&quot;: &quot;1&quot;,
                &quot;provided_name&quot;: &quot;magento2_product_41_v18&quot;,
                &quot;max_result_window&quot;: &quot;100000&quot;,
                &quot;creation_date&quot;: &quot;1665213507317&quot;,
                &quot;analysis&quot;: {
                    &quot;filter&quot;: {
                        &quot;default_stemmer&quot;: {
                            &quot;type&quot;: &quot;stemmer&quot;,
                            &quot;language&quot;: &quot;english&quot;
                        },
                        &quot;unique_stem&quot;: {
                            &quot;type&quot;: &quot;unique&quot;,
                            &quot;only_on_same_position&quot;: &quot;true&quot;
                        }
                    },
                    &quot;char_filter&quot;: {
                        &quot;default_char_filter&quot;: {
                            &quot;type&quot;: &quot;html_strip&quot;
                        }
                    },
                    &quot;analyzer&quot;: {
                        &quot;prefix_search&quot;: {
                            &quot;filter&quot;: &#x5B;
                                &quot;lowercase&quot;,
                                &quot;keyword_repeat&quot;
                            ],
                            &quot;char_filter&quot;: &#x5B;
                                &quot;default_char_filter&quot;
                            ],
                            &quot;type&quot;: &quot;custom&quot;,
                            &quot;tokenizer&quot;: &quot;default_tokenizer&quot;
                        },
                        &quot;default&quot;: {
                            &quot;filter&quot;: &#x5B;
                                &quot;lowercase&quot;,
                                &quot;keyword_repeat&quot;,
                                &quot;default_stemmer&quot;,
                                &quot;unique_stem&quot;
                            ],
                            &quot;char_filter&quot;: &#x5B;
                                &quot;default_char_filter&quot;
                            ],
                            &quot;type&quot;: &quot;custom&quot;,
                            &quot;tokenizer&quot;: &quot;default_tokenizer&quot;
                        },
                        &quot;sku_prefix_search&quot;: {
                            &quot;filter&quot;: &#x5B;
                                &quot;lowercase&quot;,
                                &quot;keyword_repeat&quot;
                            ],
                            &quot;type&quot;: &quot;custom&quot;,
                            &quot;tokenizer&quot;: &quot;keyword&quot;
                        },
                        &quot;sku&quot;: {
                            &quot;filter&quot;: &#x5B;
                                &quot;lowercase&quot;,
                                &quot;keyword_repeat&quot;,
                                &quot;default_stemmer&quot;,
                                &quot;unique_stem&quot;
                            ],
                            &quot;type&quot;: &quot;custom&quot;,
                            &quot;tokenizer&quot;: &quot;keyword&quot;
                        }
                    },
                    &quot;tokenizer&quot;: {
                        &quot;default_tokenizer&quot;: {
                            &quot;type&quot;: &quot;standard&quot;
                        }
                    }
                },
                &quot;number_of_replicas&quot;: &quot;1&quot;,
                &quot;uuid&quot;: &quot;3hoUumFITJi9cSnhwNDXog&quot;,
                &quot;version&quot;: {
                    &quot;created&quot;: &quot;7170499&quot;
                }
            }
        }
    }
}
</pre></div>


<h6 class="wp-block-heading">Get All Index Mapping</h6>



<p>Here commerce_product_1 is the index name, replace it with * to get the mapping for all the indices</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/commerce_product_1/_mapping&#039;
</pre></div>


<h6 class="wp-block-heading">Get Mapping for a Specific Field</h6>



<p>To get the mapping details of a specific field. In the below query "barcode" is the field name. Replace * with index name to get for specific index</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_mapping/field/barcode&#039;
</pre></div>


<p>Sample Response</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; title: ; notranslate">
{
    &quot;magento2_product_38_v28&quot;: {
        &quot;mappings&quot;: {
            &quot;barcode&quot;: {
                &quot;full_name&quot;: &quot;barcode&quot;,
                &quot;mapping&quot;: {
                    &quot;aims_barcode&quot;: {
                        &quot;type&quot;: &quot;text&quot;,
                        &quot;fields&quot;: {
                            &quot;keyword&quot;: {
                                &quot;type&quot;: &quot;keyword&quot;
                            }
                        },
                        &quot;copy_to&quot;: &#x5B;
                            &quot;_search&quot;
                        ]
                    }
                }
            }
        }
    },
</pre></div>


<h6 class="wp-block-heading">Get Index Mapping Fields Count</h6>



<p>To get the mapping fields count of all the indices. Replace * with index name to get for specific index</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/*/_settings/index.mapping.total_fields*&#039;
</pre></div>


<p><strong>Sample Response</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
{
    &quot;commerce_product_5_v9&quot;: {
        &quot;settings&quot;: {
            &quot;index&quot;: {
                &quot;mapping&quot;: {
                    &quot;total_fields&quot;: {
                        &quot;limit&quot;: &quot;1267&quot;
                    }
                }
            }
        }
    },
    &quot;commerce_product_1_v9&quot;: {
        &quot;settings&quot;: {
            &quot;index&quot;: {
                &quot;mapping&quot;: {
                    &quot;total_fields&quot;: {
                        &quot;limit&quot;: &quot;1267&quot;
                    }
                }
            }
        }
    }
}
</pre></div>


<h6 class="wp-block-heading">To get the Heap Size</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/_cat/nodes?h=heap*&amp;v&#039;
</pre></div>


<p>Sample Response</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; gutter: false; title: ; notranslate">
heap.current heap.percent heap.max
       1.2gb           44    2.8gb

</pre></div>


<h6 class="wp-block-heading">To get the cluster Health</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/_cluster/health&#039;
</pre></div>


<p><strong>Sample Output</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; gutter: false; title: ; notranslate">
{
    &quot;cluster_name&quot;: &quot;elasticsearch&quot;,
    &quot;status&quot;: &quot;yellow&quot;,
    &quot;timed_out&quot;: false,
    &quot;number_of_nodes&quot;: 1,
    &quot;number_of_data_nodes&quot;: 1,
    &quot;active_primary_shards&quot;: 27,
    &quot;active_shards&quot;: 27,
    &quot;relocating_shards&quot;: 0,
    &quot;initializing_shards&quot;: 0,
    &quot;unassigned_shards&quot;: 20,
    &quot;delayed_unassigned_shards&quot;: 0,
    &quot;number_of_pending_tasks&quot;: 0,
    &quot;number_of_in_flight_fetch&quot;: 0,
    &quot;task_max_waiting_in_queue_millis&quot;: 0,
    &quot;active_shards_percent_as_number&quot;: 57.446808510638306
}
</pre></div>


<h6 class="wp-block-heading">To list the pending task of elastic search</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/_cluster/pending_tasks&#039;
</pre></div>


<h6 class="wp-block-heading">To get the node stats</h6>



<p>This output will contain details of documents, shards, indexing, search etc</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; title: ; notranslate">
curl --location --request GET &#039;http://localhost:9200/_nodes/stats&#039;
</pre></div>


<h3 class="wp-block-heading">Update Elasticsearch Settings</h3>



<p>To update a setting to a specific index replace * with index name</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
curl --location --request PUT &#039;http://localhost:9200/*/_settings&#039; \
--header &#039;Content-Type: application/json&#039; \
--data-raw &#039;{ &quot;index&quot; : { &quot;max_result_window&quot;: 3 } }&#039;
</pre></div>


<p></p>



<p></p>



<p></p>



<p></p><p>The post <a href="https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/">Magento 2 - Useful Elasticsearch Commands</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Magento 2 - Elastic Search Concepts for a Magento Developer</title>
		<link>https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=magento2-elastic-search-concepts-magento-developer</link>
					<comments>https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/#comments</comments>
		
		<dc:creator><![CDATA[mosesdinakaran@gmail.com]]></dc:creator>
		<pubDate>Sun, 09 Oct 2022 14:45:07 +0000</pubDate>
				<category><![CDATA[Elastic Search]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://mosesdinakaran.in/?p=1018</guid>

					<description><![CDATA[<p>Related Articles Elastic Search is a powerful search and analytics engine. It is known for its distributed nature, speed, and scalability. This document covers the important concepts of elastic search that would require for a magento developer The Elasticsearch Instance Once Elasticsearch is installed and running you have the instance of the Elasticsearch also known [&#8230;]</p>
<p>The post <a href="https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/">Magento 2 - Elastic Search Concepts for a Magento Developer</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Related Articles</p>



<ul class="lcp_catlist" id="lcp_instance_0"><li><a href="https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/" class="lcp_title_maroon">How to Enable 'eq' Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</a></li><li><a href="https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/" class="lcp_title_maroon">Magento 2 - Useful Elasticsearch Commands</a></li><li class="current"><a href="https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/" class="lcp_title_maroon">Magento 2 - Elastic Search Concepts for a Magento Developer</a></li><li><a href="https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/" class="lcp_title_maroon">Magento 2 - How data is fetched from Elasticserach</a></li><li><a href="https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/" class="lcp_title_maroon">How Product Data is Pushed to Elasticsearch from Magento</a></li><li><a href="https://mosesdinakaran.in/elastic-search-for-magento-developer/" class="lcp_title_maroon">Elastic Search for Magento Developer</a></li></ul>



<p></p>



<p>Elastic Search is a powerful search and analytics engine. It is known for its distributed nature, speed, and scalability. This document covers the important concepts of elastic search that would require for a magento developer</p>



<h3 class="wp-block-heading"><a>The Elasticsearch Instance</a></h3>



<p>Once Elasticsearch is installed and running you have the instance of the Elasticsearch also known as node.</p>



<p>Elasticsearch Instance == Node</p>



<p>A node contains unique ID and Name and belongs to a single cluster. When you start elasticsearch instance (node) a cluster is automatically created. A cluster can have 1 to n nodes. Nodes can be distributed in several machines but still they can be part of single cluster.</p>



<h5 class="wp-block-heading"><a>Document</a></h5>



<p>Elasticsearch stores data as JSON documents. Each document correlates a set of keys (names of fields or properties) with their corresponding values (strings, numbers, Booleans, dates, arrays of values, geolocations, or other types of data). Every document contains a unique ID</p>



<h5 class="wp-block-heading"><a>Indices</a></h5>



<p>Document that shares similarities are grouped in to indices. Multiple Index can be stored in a node. Index is just a virtual thing that knows where the data is stored, Data is actually stored in the shard.</p>



<ul class="wp-block-list"><li>MySQL =&gt; Databases =&gt; Tables =&gt; Columns/Rows</li><li>Elasticsearch =&gt; Indices =&gt; Types =&gt; Documents with Properties</li></ul>



<h5 class="wp-block-heading">Shard</h5>



<p>Shard is where data is stored, this is where you run your search query. When you create an index, a shard is created by default. No of documents that a shard can store depends on the size of the document and the instance size. Shards are horizontally scalable. A Single index can be stored across multiple nodes.</p>



<p>The total no of index you have in the node, the total no of shards will be created. This no can be changed based on the index.number_of_shards configuration.</p>



<h5 class="wp-block-heading">Sharding</h5>



<p>The practice of creating an index with multiple shards is called sharding. Its explained in the below image. Here we have elasticsearch with three instance and contains two indexes. These indexes are shared in all three instances. Each index contains 2 shards.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="940" height="703" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image.png" alt="" class="wp-image-1020" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-300x224.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-768x574.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-441x330.png 441w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-241x180.png 241w" sizes="(max-width: 940px) 100vw, 940px" /></figure>



<p>There are two main reasons why sharding is important,</p>



<ul class="wp-block-list"><li>With the first one being that it allows you to split and thereby scale volumes of data.</li><li>The other reason is that operations can be distributed across multiple nodes and thereby parallelized. This results in increased performance because multiple machines can potentially work on the same query.</li></ul>



<p>To Avoid data loss, use replica of shards.</p>



<p>A cluster with too many indices or shards is said to suffer from&nbsp;oversharding. An oversharded cluster will be less efficient. The best way to prevent oversharding and other shard-related issues is to create a sharding strategy.</p>



<h3 class="wp-block-heading">Index Mapping</h3>



<p>Every index in an elastic search contains a mapping.</p>



<p>Mapping determines how a document, and its field are stored and indexed. It will define which fields needs to be indexed and which not. Mapping plays a important role in how ES stores and searches the data. Depending upon the use cases the mapping can be customized to make storage and indexing more efficient.</p>



<p>If a mapping is not defined, Elasticsearch defined its own mapping based on the document data this is called dynamic mapping.</p>



<p>A sample mapping is shown below.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="940" height="723" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-1.png" alt="" class="wp-image-1021" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-1.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-1-300x231.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-1-768x591.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-1-429x330.png 429w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-1-234x180.png 234w" sizes="(max-width: 940px) 100vw, 940px" /></figure>



<p>The data is Elasticsearch &nbsp;is stored as TEXT or KEYWORD. By Default, every string get mapped by both text and keyword. This can be changed based on our requirement.</p>



<p>Only One mapping will be created for a index, After the mapping is created we cannot edit the existing field but we can add new fields to mapping. If we need to edit the existing mapping, we need to delete the indices and create a new once.</p>



<h2 class="wp-block-heading"><a>Elasticsearch Indexing</a></h2>



<p>When a document is stored, it is indexed and fully searchable in&nbsp;near real-time--within 1 second. Elasticsearch uses a data structure called an inverted index that supports very fast full-text searches. An inverted index lists every unique word that appears in any document and identifies all the documents each word occurs in.</p>



<p>Any field in Elasticsearch can be of type Text or Keyword.</p>



<ul class="wp-block-list"><li>Text  --&gt;  Full Text Search</li><li>Keyword --&gt; Keyword is defined for Exact Search, Aggregation and Sorting.</li></ul>



<p></p>



<h5 class="wp-block-heading"><a>Text Field Indexing</a></h5>



<p>Lets see how the text field indexing works, For our ex we will take the product attribute description which contains the  below text mapping</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&quot;description&quot;: {
        &quot;type&quot;: &quot;text&quot;
}
</pre></div>


<pre class="wp-block-preformatted">and the data that we are inserting is “These pineapples are sourced from New Zealand.”</pre>



<p>By default, strings are analyzed when it is indexed. The string is broken up into individual words also known as tokens. The analyzer further lowercases each token and removes punctuations. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="748" height="380" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-3.png" alt="" class="wp-image-1023" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-3.png 748w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-3-300x152.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-3-570x290.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-3-270x137.png 270w" sizes="auto, (max-width: 748px) 100vw, 748px" /></figure>



<pre class="wp-block-preformatted">Once the text are analyzed its stored in the inverted Index</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="475" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-4.png" alt="" class="wp-image-1024" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-4.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-4-300x152.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-4-768x388.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-4-570x288.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-4-270x136.png 270w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure>



<pre class="wp-block-preformatted">Now that we have the data indexed if the client is searching for the word pineapples, The ES just need to look for the term pineapples in the inverted index and be able to find the doc id.</pre>



<p>In short inverted index is&nbsp; </p>



<ul class="wp-block-list"><li>words --&gt; to --&gt; documents.</li></ul>



<p>Only&nbsp;<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html">text</a>&nbsp;fields support the&nbsp;analyzer&nbsp;mapping parameter.</p>



<h3 class="wp-block-heading"><a>Keyword Field Indexing</a></h3>



<p>When a keyword field is created, the content of the field is not analyzed and not stored in the inverted index instead Elasticsearch uses a data structure call the DOC value</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="521" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-5.png" alt="" class="wp-image-1025" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-5.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-5-300x166.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-5-768x426.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-5-570x316.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-5-270x150.png 270w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure>



<p>So for each document, the document id along with the field value the actual string is stored as is. This data structure is optimal for exact search aggregation and sorting.</p>



<h2 class="wp-block-heading"><a>Search Relevance &amp; Full text Search</a></h2>



<p>A search is made up of 2 parts Relevance and Ranking</p>



<h3 class="wp-block-heading"><a>Relevance:</a></h3>



<p>All Relevant documents that match a certain query. Precision / Quality(AND) and Recall /Quantity ( OR) determines which document are relevant for the search query but it will not determine which is the most relevant compared to the other.</p>



<p>i.e Precision and Recall will include all the available "Phones" but it will not tell which phone should be listed first.</p>



<h3 class="wp-block-heading"><a>Ranking:</a></h3>



<p>This determines which record should come first. Ranking of a document is determined by score using a scoring algorithm. A score is a value that represents how relevant a document for a specific query. A score for a document is determined by multiple factors such as</p>



<h3 class="wp-block-heading"><a>Term Frequency</a></h3>



<p>How Often the search term appears in this document. More frequency == More often</p>



<h3 class="wp-block-heading"><a>Inverse Document Frequency</a></h3>



<p>How often does this term appear in all the documents. The more often the lower the weight. For ex Buy Mobile for Rs 10000</p>



<p>Here Buy and for will appear more in all the document which will reduce its weight</p>



<h3 class="wp-block-heading"><a>Vector Space Model</a></h3>



<p>This provides a way for comparing a multi term query against a document.</p>



<h3 class="wp-block-heading"><a>Field Length normalization</a></h3>



<p>How long is the field, The shorter the higher the weight ex title vs body</p>



<h2 class="wp-block-heading"><a>Aggregation</a></h2>



<p>There are 2 main ways to fetch data from Elasticsearch.</p>



<p><strong>Query</strong></p>



<ul class="wp-block-list"><li>Retrieve document that matches the specific search criteria. Ex Search All Products with Name “Mobile Phones”</li></ul>



<p><strong>Aggregation</strong></p>



<ul class="wp-block-list"><li>Summarizes your data as metrics, statistics and other analytics Ex What is the total no of Mobiles that belongs to Apple Brand</li></ul>



<p>Elasticsearch organizes aggregations into three categories:</p>



<h3 class="wp-block-heading"><a>Metric&nbsp;Aggregation</a></h3>



<p>Aggregations that calculate metrics, such as a sum or average, from field values.</p>



<h3 class="wp-block-heading"><a>Bucket&nbsp;aggregations</a></h3>



<p>When you want to aggregate document on several subset of documents based on the field value, range or other criteria bucket aggregation will be handy. Bucket aggregation groups documents into several set of documents called Bucket all document within a bucket share a same criteria.</p>



<h3 class="wp-block-heading"><a>Pipeline</a>&nbsp;aggregation</h3>



<p>Aggregations that take input from other aggregations instead of documents or fields are called pipeline aggregation.</p>



<p>The below is a sample aggregation query.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="593" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-6.png" alt="" class="wp-image-1027" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-6.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-6-300x189.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-6-768x484.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-6-523x330.png 523w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-6-270x170.png 270w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure><p>The post <a href="https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/">Magento 2 - Elastic Search Concepts for a Magento Developer</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Magento 2 - How data is fetched from Elasticserach</title>
		<link>https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=magento-2-how-data-is-fetched-from-elasticserach</link>
					<comments>https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/#respond</comments>
		
		<dc:creator><![CDATA[mosesdinakaran@gmail.com]]></dc:creator>
		<pubDate>Sun, 09 Oct 2022 14:44:57 +0000</pubDate>
				<category><![CDATA[Elastic Search]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://mosesdinakaran.in/?p=1126</guid>

					<description><![CDATA[<p>Related Articles Overview Once we have the product data pushed to Elasticsearch we can now use ES API's to fetch data. The data from ES helps to Identify the products ids that are relevant for the specific search query. Filter Navigation / Aggregation Once we have the products ids, The relevant product data such as [&#8230;]</p>
<p>The post <a href="https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/">Magento 2 - How data is fetched from Elasticserach</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>Related Articles</strong></p>



<ul class="lcp_catlist" id="lcp_instance_0"><li><a href="https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/" class="lcp_title_maroon">How to Enable 'eq' Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</a></li><li><a href="https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/" class="lcp_title_maroon">Magento 2 - Useful Elasticsearch Commands</a></li><li><a href="https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/" class="lcp_title_maroon">Magento 2 - Elastic Search Concepts for a Magento Developer</a></li><li class="current"><a href="https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/" class="lcp_title_maroon">Magento 2 - How data is fetched from Elasticserach</a></li><li><a href="https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/" class="lcp_title_maroon">How Product Data is Pushed to Elasticsearch from Magento</a></li><li><a href="https://mosesdinakaran.in/elastic-search-for-magento-developer/" class="lcp_title_maroon">Elastic Search for Magento Developer</a></li></ul>



<h3 class="wp-block-heading">Overview</h3>



<p>Once we have the product data pushed to Elasticsearch we can now use ES API's to fetch data. </p>



<p>The data from ES helps to </p>



<ol class="wp-block-list" type="1"><li>Identify the products ids that are relevant for the specific search query.</li><li>Filter Navigation / Aggregation</li></ol>



<p>Once we have the products ids, The relevant product data such as pricing, inventory, product attributes are fetched from the mysql directly.</p>



<p>A search request to elastic search contains 3 parts.</p>



<ol class="wp-block-list" type="1"><li>The Search String</li><li>Sorting</li><li>Aggregation (Filter Navigation)</li></ol>



<p>These requests are built based on configuration in search_request.xml file. By default, Magento uses the following query types:</p>



<ul class="wp-block-list"><li>quick_search_container&nbsp;– Quick Search</li><li>advanced_search_container&nbsp;– Advanced Search</li><li>catalog_view_container&nbsp;– Category page with layered navigation</li><li>graphql_product_search_with_aggregation&nbsp;– Used by GraphQL API when you pass aggregation query</li><li>graphql_product_search&nbsp;– Used by GraphQL API</li></ul>



<p>Code Reference :</p>



<ul class="wp-block-list"><li>vendor/magento/module-catalog-graph-ql/etc/search_request.xml</li></ul>



<h3 class="wp-block-heading" id="aioseo-1-7-1-the-search-query">The Search Query</h3>



<p>There are three types are search query defined in search_request.xml</p>



<ul class="wp-block-list"><li>boolQuery</li><li>matchQuery</li><li>filteredQuery</li></ul>



<p>With the bool query, you can combine multiple queries into one request and further specify boolean clauses to narrow down your search results.<br>There are four clauses to choose from:</p>



<ul class="wp-block-list"><li>Must<ul><li>One or more queries can be specified here. A document MUST match all of these queries to be considered as a hit.</li></ul></li><li>must_not<ul><li>A document must NOT match any of the queries specified here. It it does, it is excluded from the search results.</li></ul></li><li>Should<ul><li>A document does not have to match any queries specified here. However, it if it does match, this document is given a higher score.</li></ul></li><li>Filter<ul><li>These filters(queries) place documents in either yes or no category. Ones that fall into the yes category are included in the hits.<br>You can build combinations of one or more of these clauses. Each clause can contain one or multiple queries that specify the criteria of each clause.<br>These clauses are optional and can be mixed and matched to cater to your use case. The order in which they appear does not matter either!</li></ul></li></ul>



<p>Syntax:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
GET name_of_index/_search
{
  &quot;query&quot;: {
    &quot;bool&quot;: {
      &quot;must&quot;: &#x5B;
	Filter by attributes, Category Ids, Visibility
      ],
      &quot;should&quot;: &#x5B;
        { The Search String }
      ],
    }
  }
}

</pre></div>


<h3 class="wp-block-heading">How Search Query is Generated</h3>



<p>The search queries are defined in the below 4 files, Based on the type of search request the respective container is selected.</p>



<ul class="wp-block-list"><li>vendor/magento/module-elasticsearch-catalog-permissions/etc/search_request.xml</li><li>vendor/magento/module-elasticsearch-catalog-permissions-graph-ql/etc/search_request.xml</li><li>vendor/magento/module-catalog-graph-ql/etc/search_request.xml</li><li>vendor/magento/module-catalog-search/etc/search_request.xml</li></ul>



<p>When search request is processed these xml files are processed and the relevant search query is generated and stored in the cache. The process of generating the search aggregation query is explained below</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>File Reference</strong></td><td><strong>Comments</strong></td></tr><tr><td>\Magento\Framework\Config\Data::initData</td><td>XML file content and parsed and merged</td></tr><tr><td>\Magento\Framework\Search\Request\Config\Converter::convert</td><td>Search Query is formed <br><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-23.png" alt=""></td></tr><tr><td>\Magento\CatalogSearch\Model\Search\Request\SearchModifier::modify</td><td>At this point we will have the category and price bucket generated but filterable attribute bucket are not generated yet</td></tr><tr><td>\Magento\CatalogSearch\Model\Search\RequestGenerator::generate \Magento\CatalogSearch\Model\Search\RequestGenerator::generateRequest</td><td>At this point all the filterable bucket attributes are generated. $request['aggregations'][$bucketName] = $generator-&gt;getAggregationData($attribute, $bucketName); &nbsp;</td></tr></tbody></table></figure>



<p>The ouput of these parsed xml files is stored in the $data array</p>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="709" height="200" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-24.png" alt="" class="wp-image-1161" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-24.png 709w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-24-300x85.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-24-570x161.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-24-270x76.png 270w" sizes="auto, (max-width: 709px) 100vw, 709px" /></figure>



<p></p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Container</strong></td><td><strong>Sample Data</strong></td></tr><tr><td>Quick Search Container</td><td><img loading="lazy" decoding="async" width="483" height="344" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-31.png" alt=""></td></tr><tr><td>Catalog View Container</td><td><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-26.png" alt=""></td></tr><tr><td>GraphQl Product Search With Aggregation</td><td><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-32.png" alt=""></td></tr><tr><td>GraphQl Product Search</td><td><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-28.png" alt=""></td></tr></tbody></table></figure>



<p></p>



<p>Lets see some actual elastic search requests that gets triggered in real time.</p>



<h3 class="wp-block-heading" id="aioseo-1-7-1-1-category-page-query">Category Page Query</h3>



<p>To List all the Products from a specific Category</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Frontend URL</strong></td><td><strong>Elastic Search Request</strong></td></tr><tr><td>Category Page<br>http://commerce.development/gear/bags.html<br><br></td><td>URL:<br>http://localhost:9200/commerce_product_1/document/_search?track_total_hits=true<br><br>Body:<br><img decoding="async" style="width: 500px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-16.png" alt=""></td></tr><tr><td>Category Page with Filter Selected<br>http://commerce.development/gear/bags.html?material=47</td><td>Api Request: <br>http://localhost:9200/commerce_product_1/document/_search?track_total_hits=true<br><br>Request Body:<br><br><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-17.png" alt=""><br></td></tr></tbody></table></figure>



<h3 class="wp-block-heading" id="aioseo-1-7-1-2-search-page-query">Search Page Query</h3>



<p>If you are searching for a string “pack” the below query is issues to elastic search</p>



<p>Frontend URL : http://commerce.development/catalogsearch/result/?q=pack</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="561" height="923" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-18.png" alt="" class="wp-image-1152" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-18.png 561w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-18-182x300.png 182w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-18-201x330.png 201w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-18-109x180.png 109w" sizes="auto, (max-width: 561px) 100vw, 561px" /></figure>



<p>In Short difference between PLP and Search Page query is the query clause</p>



<ul class="wp-block-list"><li>PLP -&gt; must</li><li>Search Page -&gt; must &amp; should</li></ul>



<h3 class="wp-block-heading" id="aioseo-1-7-2-sorting">Sorting</h3>



<p>By default magneto supports position, product name and price sorting. Additional attributes can be added for sorting. In that case the respective mapping will get updated note that a full reindexing is required in that case.</p>



<p>Below are the few sort query examples.</p>



<figure class="wp-block-table"><table><tbody><tr><td>Sort By Position</td><td><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-19.png" alt=""></td></tr><tr><td>Sort By Name</td><td><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-20.png" alt=""></td></tr></tbody></table></figure>



<h3 class="wp-block-heading" id="aioseo-1-7-3-filter-navigation-aggregation">Filter Navigation / Aggregation</h3>



<p>The data for the filter navigation is generated using the aggregation buckets in the search query</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Search Query</strong></td><td><strong>Frontend Display</strong></td></tr><tr><td><img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-21.png" alt=""></td><td>&nbsp; <img decoding="async" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-22.png" alt=""></td></tr></tbody></table></figure>



<p></p>



<p>There are primarily three types of aggregation buckets</p>



<ul class="wp-block-list"><li>Category Bucket</li><li>Price Bucket</li><li>Filterable Product Attributes Bucket</li></ul>



<p></p>



<p>The Response from the aggregation bucket from the elastic search will be like the below</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="568" height="1024" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-29-568x1024.png" alt="" class="wp-image-1166" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-29-568x1024.png 568w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-29-166x300.png 166w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-29-183x330.png 183w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-29-100x180.png 100w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-29.png 653w" sizes="auto, (max-width: 568px) 100vw, 568px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="502" height="656" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-30.png" alt="" class="wp-image-1167" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-30.png 502w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-30-230x300.png 230w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-30-253x330.png 253w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-30-138x180.png 138w" sizes="auto, (max-width: 502px) 100vw, 502px" /></figure>



<p>These data from the response is parsed and displayed in the Frontend Filtered Navigation</p>



<p></p>



<p></p><p>The post <a href="https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/">Magento 2 - How data is fetched from Elasticserach</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How Product Data is Pushed to Elasticsearch from Magento</title>
		<link>https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-product-data-is-pushed-to-elasticsearch-from-magento</link>
					<comments>https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/#respond</comments>
		
		<dc:creator><![CDATA[mosesdinakaran@gmail.com]]></dc:creator>
		<pubDate>Sun, 09 Oct 2022 14:44:34 +0000</pubDate>
				<category><![CDATA[Elastic Search]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://mosesdinakaran.in/?p=1034</guid>

					<description><![CDATA[<p>Related Articles To serve data from elastic search we first need to push data to elastic search, This is done through the catalog search fulltext indexing. Lets explore more in to this through the below sections. Identity the Relevant Products to Push to Elasticsearch The products that are enabled, visibility = catalog search will be [&#8230;]</p>
<p>The post <a href="https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/">How Product Data is Pushed to Elasticsearch from Magento</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></description>
										<content:encoded><![CDATA[<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%"></div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<p><strong>Related Articles</strong></p>



<ul class="lcp_catlist" id="lcp_instance_0"><li><a href="https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/" class="lcp_title_maroon">How to Enable 'eq' Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</a></li><li><a href="https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/" class="lcp_title_maroon">Magento 2 - Useful Elasticsearch Commands</a></li><li><a href="https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/" class="lcp_title_maroon">Magento 2 - Elastic Search Concepts for a Magento Developer</a></li><li><a href="https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/" class="lcp_title_maroon">Magento 2 - How data is fetched from Elasticserach</a></li><li class="current"><a href="https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/" class="lcp_title_maroon">How Product Data is Pushed to Elasticsearch from Magento</a></li><li><a href="https://mosesdinakaran.in/elastic-search-for-magento-developer/" class="lcp_title_maroon">Elastic Search for Magento Developer</a></li></ul>
</div>
</div>



<p>To serve data from elastic search we first need to push data to elastic search, This is done through the catalog search fulltext indexing. </p>



<p>Lets explore more in to this through the below sections.</p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-identity-the-relevant-products-to-push-to-elasticsearch">Identity the Relevant Products to Push to Elasticsearch</h3>



<p>The products that are enabled, visibility = catalog search will be pushed to elastic search. Each product data will be stored in the elastic search as a document.</p>



<p>A sample product data would be like the following</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="926" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-7.png" alt="" class="wp-image-1039" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-7.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-7-300x296.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-7-768x757.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-7-335x330.png 335w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-7-183x180.png 183w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure>



<p>In the case of configurable product, The data from the child product is also merged and then pushed to elastic search. For ex if we have the below configurable product with 3 children where each child has a separate barcode.</p>



<p></p>



<figure class="wp-block-table"><table><tbody><tr><td class="has-text-align-left" data-align="left"><strong>Configurable Product</strong></td><td class="has-text-align-left" data-align="left"><strong>Child Product</strong></td><td><strong>Elasticsearch Data</strong></td></tr><tr><td class="has-text-align-left" data-align="left">Name : Shirt<br>Barcode : &lt;null&gt;</td><td class="has-text-align-left" data-align="left">Name : Red Shirt<br>Barcode : 10001<br>-----------------<br>Name : Blue Shirt<br>Barcode : 10002<br>------------------<br>Name : Green Shirt<br>Barcode : 10002</td><td>{<br>"Name" : [<br>Shirt<br>Red Shirt<br>Blue Shirt<br>Green Shirt<br>]<br>"Barcode" : [<br>10001<br>10002<br>10003<br>]<br>}</td></tr></tbody></table></figure>



<p>Reference :</p>



<ul class="wp-block-list"><li>\Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::rebuildStoreIndex</li><li>\Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::getSearchableProducts<ul><li>Fetches all the products that needs to be send to elastic search</li></ul></li></ul>



<h3 class="wp-block-heading" id="aioseo-generate-elasticsearch-index-name">Generate Elasticsearch Index Name</h3>



<p>The first step in creating the elastic search index is to generate an index name. Magento creates a separate elastic search Indices for each store view.&nbsp; For ex if we have 4 store views then 4 indices will be created as show below.</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>store_id</strong><strong></strong></td><td><strong>code</strong><strong></strong></td><td><strong>website_id</strong><strong></strong></td><td><strong>name</strong><strong></strong></td><td><strong>ES Index Name</strong><strong></strong></td></tr><tr><td><strong>1</strong><strong></strong></td><td>kwt_en</td><td>1</td><td>Kuwait English Store</td><td>commerce_product_1_v15 <br>commerce_product_1_v16</td></tr><tr><td><strong>2</strong><strong></strong></td><td>kwt_ar</td><td>1</td><td>Kuwait Arabic Store</td><td>&nbsp;commerce_product_2_v11</td></tr><tr><td><strong>3</strong><strong></strong></td><td>ind_en</td><td>2</td><td>India English Store</td><td>commerce_product_3_v11</td></tr><tr><td><strong>4</strong><strong></strong></td><td>gbr_en</td><td>3</td><td>UK Eng Store View</td><td>commerce_product_4_v11</td></tr></tbody></table></figure>



<p>At times we will see there are multiple index available for a store view, In the below table for Kuwait English Store we could see two elastic search indices are created which we will discuss later.</p>



<p>The Elasticsearch Index pattern “commerce_product_1_v15” contains the below parts</p>



<ul class="wp-block-list"><li>commerce à Index Prefix which is configurable</li><li>product àRepresent Product Index</li><li>[1|2|3..] à Store ID</li><li>[v15 | v11] à A random version no given for each index name.</li></ul>



<p>The below steps are involved to identify the index name for a store view.</p>



<p>For ex lets consider we are reindexing Kuwait English Store</p>



<ul class="wp-block-list"><li>Identify the primary index of Kuwait English Store, The primary index of a store can be identified using the elastic search alias which we will see in the next section.</li><li>Remove all the unwanted or orphaned index of Kuwait English Store apart from the primary index.<ul><li>In our case, lets assume we have two indices commerce_product_1_v15 and commerce_product_1_v16, where commerce_product_1_v16 is the primary index so commerce_product_1_v15 will get deleted.</li></ul></li><li>Now do +1 to the current primary index version so our new index name will be commerce_product_1_v17</li></ul>



<p><strong>Code Reference</strong></p>



<ul class="wp-block-list"><li>\Magento\CatalogSearch\Model\Indexer\Fulltext::executeByDimensions<ul><li>Indexing Process Starts Here</li></ul></li><li>\Magento\Elasticsearch\Model\Indexer\IndexerHandler::cleanIndex<ul><li>Delete the old unwanted Index and Create the New Index</li></ul></li><li>\Magento\Elasticsearch7\Model\Client\Elasticsearch::existsAlias<ul><li>Check if alias exists</li></ul></li></ul>



<h3 class="wp-block-heading" id="aioseo-create-the-index">Create the Index</h3>



<p>Once the index name is identified, we can not create the new index.</p>



<p>Code Reference :</p>



<ul class="wp-block-list"><li>\Magento\Elasticsearch\Model\Indexer\IndexerHandler::saveIndex</li></ul>



<h5 class="wp-block-heading" id="aioseo-index-setting">Index Setting</h5>



<p>While creating the index, Index level settings is also set such as filter setting, analyser, mapping fields count etc.</p>



<p>Request : PUT <a href="http://localhost:9200/commerce_product_1_v17">http://localhost:9200/commerce_product_1_v17</a></p>



<p>Body :</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="721" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-8.png" alt="" class="wp-image-1048" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-8.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-8-300x230.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-8-768x589.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-8-430x330.png 430w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-8-235x180.png 235w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: css; title: ; notranslate">
Response : 
{
&quot;acknowledged&quot;:true,
&quot;shards_acknowledged&quot;:true,
&quot;index&quot;:&quot;commerce_product_1_v17&quot;
}
</pre></div>


<p>The response indicates that we have created the new index commerce_product_1_v17 along with the settings.</p>



<p><strong>Code Reference: </strong></p>



<ul class="wp-block-list"><li>\Magento\Elasticsearch\Model\Adapter\Elasticsearch::prepareIndex<ul><li><em>Create new index with mapping.</em></li></ul></li></ul>



<h5 class="wp-block-heading" id="aioseo-analyzer">Analyzer </h5>



<p>The&nbsp;analyzer&nbsp;parameter specifies the&nbsp;<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer-anatomy.html">analyzer</a>&nbsp;used for&nbsp;<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html">text analysis</a>&nbsp;when indexing or searching a&nbsp;text&nbsp;field.</p>



<p>An&nbsp;<em>analyzer</em>&nbsp; — whether built-in or custom — is just a package which contains three lower-level building blocks:&nbsp;<em>character filters</em>,&nbsp;<em>tokenizers</em>, and&nbsp;<em>token filters</em>.</p>



<h6 class="wp-block-heading" id="aioseo-tokenizer">Tokenizer</h6>



<p>A tokenizer receives a stream of characters, breaks it up into individual tokens (usually individual words), and outputs a stream of tokens. For instance, a whitespace tokenizer breaks text into tokens whenever it sees any whitespace. It would convert the text "Quick brown fox!" into the terms [Quick, brown, fox!].</p>



<h6 class="wp-block-heading" id="aioseo-character-filters">Character filters</h6>



<p>A character filter receives the original text as a stream of characters and can transform the stream by adding, removing, or changing characters</p>



<h6 class="wp-block-heading" id="aioseo-token-filter">Token filter</h6>



<p>A token filter receives the token stream and may add, remove, or change tokens. For example, a lowercase token filter converts all tokens to lowercase, a stop token filter removes common words (stop words) like the from the token stream, and a synonym token filter introduces synonyms into the token stream.</p>



<p><strong>Code Reference</strong></p>



<ul class="wp-block-list"><li>\Magento\Elasticsearch\Model\Adapter\Index\Builder::build<ul><li><em>Set the analyzer setting</em></li></ul></li></ul>



<h3 class="wp-block-heading" id="aioseo-create-index-mapping">Create Index Mapping</h3>



<p>Before we start pushing the data to the index, we need to create the index mapping.</p>



<p>The mapping will be created for each and every product attribute that is available in the store.</p>



<p>Depending on the product attribute type the mapping type is set. Below are the few sample mapping</p>



<h5 class="wp-block-heading" id="aioseo-searchable-product-attributes">Searchable Product Attributes.</h5>



<p>All the product attributes that is set to use in Search will be pushed to elastic search.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="697" height="147" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-9.png" alt="" class="wp-image-1055" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-9.png 697w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-9-300x63.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-9-570x120.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-9-270x57.png 270w" sizes="auto, (max-width: 697px) 100vw, 697px" /></figure>



<p>And based on the attribute input type the relevant mappings are set.</p>



<p>For ex, Lets have a look at the below product data.</p>



<p><img loading="lazy" decoding="async" width="300" height="80" class="wp-image-1062" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/5.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/5.png 321w, https://mosesdinakaran.in/wp-content/uploads/2022/10/5-300x80.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/5-270x72.png 270w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>



<figure class="wp-block-table"><table><tbody><tr><td>Name</td><td>Sku</td><td>Url Key</td><td>Description</td></tr><tr><td><img loading="lazy" decoding="async" width="300" height="271" class="wp-image-1061" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/4.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/4.png 269w, https://mosesdinakaran.in/wp-content/uploads/2022/10/4-199x180.png 199w" sizes="auto, (max-width: 300px) 100vw, 300px" /><br></td><td><img loading="lazy" decoding="async" width="300" height="238" class="wp-image-1060" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/3.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/3.png 243w, https://mosesdinakaran.in/wp-content/uploads/2022/10/3-227x180.png 227w" sizes="auto, (max-width: 300px) 100vw, 300px" /></td><td><img loading="lazy" decoding="async" width="300" height="196" class="wp-image-1059" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/2.png" alt=""></td><td><img loading="lazy" decoding="async" width="300" height="163" class="wp-image-1058" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/1.png" alt=""></td></tr></tbody></table></figure>



<p> The&nbsp;<code>copy_to</code>&nbsp;parameter allows you to copy the values of multiple fields into a group field, which can then be queried as a single field. </p>



<p>So while searching for a record either in listing page or graphql etc, magento appends the below match query automatically. </p>



<p><img loading="lazy" decoding="async" width="300" height="146" class="wp-image-1063" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/6.png" alt=""><br>So basically instead of searching in each field we search in _search field as all the values are copied here.</p>



<p>For the name attribute we see fields.sort_[attrbutecode], This is because name attribute has the sorting setting enabled.</p>



<p><img loading="lazy" decoding="async" width="300" height="71" class="wp-image-1064" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/7.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/7.png 295w, https://mosesdinakaran.in/wp-content/uploads/2022/10/7-270x64.png 270w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>



<p>In the case of description, we dont have the keyword mapping which means we cannot use the eq operator </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="691" height="542" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-10.png" alt="" class="wp-image-1103" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-10.png 691w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-10-300x235.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-10-421x330.png 421w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-10-229x180.png 229w" sizes="auto, (max-width: 691px) 100vw, 691px" /></figure>



<p>But we can use the match operator</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="626" height="389" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-11.png" alt="" class="wp-image-1104" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-11.png 626w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-11-300x186.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-11-531x330.png 531w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-11-270x168.png 270w" sizes="auto, (max-width: 626px) 100vw, 626px" /></figure>



<p>i.e For all the attributes which doesn't contains the keyword mapping we cant use eq operator to search.</p>



<p><strong>Code Reference:</strong></p>



<ul class="wp-block-list"><li>\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\CompositeFieldProvider::getFields</li></ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="414" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-12.png" alt="" class="wp-image-1105" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-12.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-12-300x132.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-12-768x338.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-12-570x251.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-12-270x119.png 270w" sizes="auto, (max-width: 940px) 100vw, 940px" /><figcaption>Based on the Product Attribute properties the mappings are set, static or dynamic</figcaption></figure>



<ul class="wp-block-list"><li>\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField::getField</li></ul>



<p></p>



<ul class="wp-block-list"><li>\Magento\Elasticsearch7\Model\Client\Elasticsearch::addFieldsMapping<ul><li>Set the mapping for each attribute</li></ul></li><li>\Magento\Elasticsearch7\Model\Client\Elasticsearch::applyFieldsMappingPreprocessors</li></ul>



<p>In case if we need to customize mapping we can do here, </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;type name=&quot;Magento\Elasticsearch7\Model\Client\Elasticsearch&quot;&gt;
    &lt;arguments&gt;
        &lt;argument name=&quot;fieldsMappingPreprocessors&quot; xsi:type=&quot;array&quot;&gt;
            &lt;item name=&quot;elasticsearch7_nested_type_field_mapping&quot; xsi:type=&quot;object&quot;&gt;YourModule\NestedFieldMapping&lt;/item&gt;
        &lt;/argument&gt;
    &lt;/arguments&gt;
&lt;/type&gt;
</pre></div>


<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="128" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-13.png" alt="" class="wp-image-1107" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-13.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-13-300x41.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-13-768x105.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-13-570x78.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-13-270x37.png 270w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure>



<p></p>



<ul class="wp-block-list"><li>&nbsp;\Elasticsearch\Namespaces\IndicesNamespace::putMapping<ul><li>Save the Mapping</li></ul></li></ul>



<h5 class="wp-block-heading" id="aioseo-filterable-product-attributes">Filterable Product Attributes</h5>



<p>All the filterable attributes will have both text and keyword mapping represented in 2 fields attrcode &amp; attrcode_value</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Mapping</strong></td><td><strong>Product Data</strong></td></tr><tr><td>&nbsp; <img loading="lazy" decoding="async" width="150" height="151" class="wp-image-1108" style="width: 150px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/8.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/8.png 195w, https://mosesdinakaran.in/wp-content/uploads/2022/10/8-150x150.png 150w, https://mosesdinakaran.in/wp-content/uploads/2022/10/8-179x180.png 179w" sizes="auto, (max-width: 150px) 100vw, 150px" /></td><td><img loading="lazy" decoding="async" width="150" height="171" class="wp-image-1109" style="width: 150px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/9.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/9.png 171w, https://mosesdinakaran.in/wp-content/uploads/2022/10/9-158x180.png 158w" sizes="auto, (max-width: 150px) 100vw, 150px" /></td></tr></tbody></table></figure>



<h5 class="wp-block-heading" id="aioseo-non-indexed-attributes">Non-Indexed Attributes</h5>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Mapping</strong></td><td><strong>Product Data</strong></td></tr><tr><td><img loading="lazy" decoding="async" width="300" height="349" class="wp-image-1111" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/10.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/10.png 216w, https://mosesdinakaran.in/wp-content/uploads/2022/10/10-155x180.png 155w" sizes="auto, (max-width: 300px) 100vw, 300px" /></td><td>We don’t push these kind of data to elastic search, But while creating the mapping still set these field and made is as index false</td></tr></tbody></table></figure>



<h5 class="wp-block-heading" id="aioseo-sorting-fields">Sorting Fields</h5>



<p>There are certain fields that is used for sorting such as Position, Product Name and Price.</p>



<p>For the purpose of position sorting position_category_[category_id] mapping is created. This mapping field is created for all the available store categories.</p>



<figure class="wp-block-table"><table><tbody><tr><td>&nbsp;Mapping</td><td>&nbsp;Product Data</td></tr><tr><td><img loading="lazy" decoding="async" width="300" height="595" class="wp-image-1113" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/11.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/11.png 225w, https://mosesdinakaran.in/wp-content/uploads/2022/10/11-151x300.png 151w, https://mosesdinakaran.in/wp-content/uploads/2022/10/11-166x330.png 166w, https://mosesdinakaran.in/wp-content/uploads/2022/10/11-91x180.png 91w" sizes="auto, (max-width: 300px) 100vw, 300px" /></td><td>&nbsp; &nbsp; <img loading="lazy" decoding="async" width="300" height="181" class="wp-image-1114" style="width: 300px;" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/12.png" alt="" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/12.png 329w, https://mosesdinakaran.in/wp-content/uploads/2022/10/12-300x181.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/12-270x162.png 270w" sizes="auto, (max-width: 300px) 100vw, 300px" /></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table></figure>



<p>While fetching the products from the es we issue the sorting query as the follows</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="523" height="184" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-14.png" alt="" class="wp-image-1116" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-14.png 523w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-14-300x106.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-14-270x95.png 270w" sizes="auto, (max-width: 523px) 100vw, 523px" /></figure>



<p></p>



<h3 class="wp-block-heading" id="aioseo-elastic-search-alias">Elastic search Alias</h3>



<p>An alias is a secondary name for a single index or a multiple indices. Magento create a alias for each store view and index (the one with version no) is assigned to the alias.</p>



<p>&nbsp;In our case we always assign one index (the primary index) to the alias as shown below.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="940" height="176" src="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-15.png" alt="" class="wp-image-1119" srcset="https://mosesdinakaran.in/wp-content/uploads/2022/10/image-15.png 940w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-15-300x56.png 300w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-15-768x144.png 768w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-15-570x107.png 570w, https://mosesdinakaran.in/wp-content/uploads/2022/10/image-15-270x51.png 270w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure>



<p>The data from the elastic search is always fetched using the alias. ex</p>



<p><a href="http://localhost:9200/commerce_product_1/document/_search">http://localhost:9200/commerce_product_1/document/_search</a>?</p>



<p>While full reindexing, Magento will not touch the current primary index that is assigned to the alias instead it will create a new index and push the data to the new index. Once all the data is pushed to the new index, The alias is switched to the new index and the old index is deleted.</p>



<h3 class="wp-block-heading" id="aioseo-index-processing-summary">Index Processing Summary</h3>



<p>The Process of creating the elasticsearch indices for a store involves the below steps, For ex lets consider we are reindexing Kuwait English Store</p>



<ul class="wp-block-list"><li>First remove all the unwanted index apart from the primary index of the respective store<ul><li>In our case, lets assume we have two indices commerce_product_1_v15 and commerce_product_1_v16, where commerce_product_1_v16 is the primary index so commerce_product_1_v15 will get deleted.</li></ul></li><li>Now create a new elastic search indices (commerce_product_1_v17) along with the index settings and mapping.</li><li>Push the data to the new index.</li><li>Once all the data is pushed to this new indices, This new indices will be set as the primary indices and the old one commerce_product_1_v16 will get removed.</li><li>So while full reindexing, The data to the frontend will be served without any interruption from the&nbsp; current primary index. On the completing of the&nbsp; reindex process the new indices will be set as the new primary index while the old one get deleted.</li></ul><p>The post <a href="https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/">How Product Data is Pushed to Elasticsearch from Magento</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Elastic Search for Magento Developer</title>
		<link>https://mosesdinakaran.in/elastic-search-for-magento-developer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=elastic-search-for-magento-developer</link>
					<comments>https://mosesdinakaran.in/elastic-search-for-magento-developer/#respond</comments>
		
		<dc:creator><![CDATA[mosesdinakaran@gmail.com]]></dc:creator>
		<pubDate>Sun, 09 Oct 2022 14:43:57 +0000</pubDate>
				<category><![CDATA[Elastic Search]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://mosesdinakaran.in/?p=1012</guid>

					<description><![CDATA[<p>As of Magento 2.4 Magento does not support MySql as a Search Engine. Now, you must install and configure Elasticsearch as your search engine before upgrading to 2.4. The below are the two primary actions involved with magento integration with elastic search which we will see in detail. Push Data The product data from Magento [&#8230;]</p>
<p>The post <a href="https://mosesdinakaran.in/elastic-search-for-magento-developer/">Elastic Search for Magento Developer</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>As of Magento 2.4 Magento does not support MySql as a Search Engine. Now, you must install and configure Elasticsearch as your search engine before upgrading to 2.4.</p>



<p>The below are the two primary actions involved with magento integration with elastic search which we will see in detail.</p>



<ul class="wp-block-list"><li>Push Data<ul><li>The product data from Magento is pushed to elastic search through catalogsearch_fulltext indexing.</li></ul></li><li>Fetch Data<ul><li>Through query and aggregation search, Ex graqlql query, plp etc</li></ul></li></ul>



<p>We can use any REST API client for interacting with Elasticsearch. Following are some sample http methods we will be using to interact</p>



<ul class="wp-block-list"><li>GET : Used to retrieve records based on query<ul><li>GET 'http://localhost:9200/magento2_product_1/_search'</li><li>GET&nbsp;'http://localhost:9200/*/_settings</li></ul></li><li>POST : Used to update the existing record in Indices<ul><li>POST&nbsp;'http://localhost:9200/indexname/_doc'</li></ul></li><li>PUT : Used to create and update the records</li><li>DELETE : To remove the existing record from indices</li></ul>



<p>Magento_Elasticsearch is the magento core module that handles the elastic search functionality. This module internally uses the third party php client <a href="https://github.com/elastic/elasticsearch)to">https://github.com/elastic/elasticsearch)to</a> communicate with the elastic search instance.</p>



<p>Code Reference</p>



<ul class="wp-block-list"><li>\Elasticsearch\Namespaces\BooleanRequestWrapper::performRequest</li><li>\Elasticsearch\Transport::performRequest<ul><li>The place where actual request that is triggered to elastic search</li></ul></li></ul>



<p>In the below articles we will look in to the elastic search concepts and how its works with Magento.</p>



<p></p>



<ul class="lcp_catlist" id="lcp_instance_0"><li><a href="https://mosesdinakaran.in/how-to-enable-eq-filter-graphql-search-for-an-custom-attribute-of-type-text-in-magento-2/" class="lcp_title_maroon">How to Enable 'eq' Filter GraphQL Search for an Custom Attribute of Type Text in Magento 2</a></li><li><a href="https://mosesdinakaran.in/magento-2-useful-elasticsearch-commands/" class="lcp_title_maroon">Magento 2 - Useful Elasticsearch Commands</a></li><li><a href="https://mosesdinakaran.in/magento2-elastic-search-concepts-magento-developer/" class="lcp_title_maroon">Magento 2 - Elastic Search Concepts for a Magento Developer</a></li><li><a href="https://mosesdinakaran.in/magento-2-how-data-is-fetched-from-elasticserach/" class="lcp_title_maroon">Magento 2 - How data is fetched from Elasticserach</a></li><li><a href="https://mosesdinakaran.in/how-product-data-is-pushed-to-elasticsearch-from-magento/" class="lcp_title_maroon">How Product Data is Pushed to Elasticsearch from Magento</a></li></ul>



<p></p>



<p></p>



<p></p><p>The post <a href="https://mosesdinakaran.in/elastic-search-for-magento-developer/">Elastic Search for Magento Developer</a> first appeared on <a href="https://mosesdinakaran.in">Moses Dinakaran</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://mosesdinakaran.in/elastic-search-for-magento-developer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
