title: Compare two fields using elastic search 7
body: <p>I don't have much idea about Elastic search. Can we compare two types of prices while fetching record from Elastic server. Here's the example</p>
  <pre><code>&quot;hits&quot;: [
          {
              &quot;_index&quot;: &quot;magento2_default_catalog_product_20210531_051304&quot;,
              &quot;_type&quot;: &quot;_doc&quot;,
              &quot;_id&quot;: &quot;57&quot;,
              &quot;_score&quot;: 1.0,
              &quot;_source&quot;: {
                  &quot;entity_id&quot;: &quot;57&quot;,
                  &quot;visibility&quot;: &quot;4&quot;,
                  &quot;price&quot;: [
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 0,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      },
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 1,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      },
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 2,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      },
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 3,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      }
                  ]
                  &quot;stock&quot;: {
                      &quot;is_in_stock&quot;: true,
                      &quot;qty&quot;: 0
                  }
              }
          },
          {
              &quot;_index&quot;: &quot;magento2_default_catalog_product_20210531_051304&quot;,
              &quot;_type&quot;: &quot;_doc&quot;,
              &quot;_id&quot;: &quot;91&quot;,
              &quot;_score&quot;: 1.0,
              &quot;_source&quot;: {
                  &quot;entity_id&quot;: &quot;91&quot;,
                  &quot;visibility&quot;: &quot;4&quot;,
                  &quot;price&quot;: [
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 0,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      },
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 1,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      },
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 2,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      },
                      {
                          &quot;price&quot;: 1.0,
                          &quot;original_price&quot;: 1.0,
                          &quot;is_discount&quot;: false,
                          &quot;customer_group_id&quot;: 3,
                          &quot;tax_class_id&quot;: 2,
                          &quot;final_price&quot;: 0.0,
                          &quot;min_price&quot;: 1.0,
                          &quot;max_price&quot;: 1.0
                      }
                  ],
                  &quot;stock&quot;: {
                      &quot;is_in_stock&quot;: true,
                      &quot;qty&quot;: 0
                  }
              }
          },
        ]
  </code></pre>
  <p>I have tons of records, now I need those records which have final_price lesser then price. Since price is an array type, I have customer group id and tax class id so I need to compare it with respective index. let's say I have customer group id as 0 and tax class id as 2 so it should compare price and final price from first index or matching index of price.</p>
  <p>Appreciate if anybody can help here.</p>