logo
down
shadow

elasticsearch comparison between fields


elasticsearch comparison between fields

By : Marc Sawaya
Date : November 21 2020, 07:31 AM
this one helps. Let's say I have documents with the following fields: {field1, field2, ... fieldn} , You can use the script filter -
code :
{
  "filtered": {
    "query": {
      "range": {
        "farePrice": {
          "gt": 100
        }
      }
    },
    "filter": {
      "script": {
        "script": "doc['originRegion'].value ==  doc['destinationRegion'].value"
      }
    }
  }
}


Share : facebook icon twitter icon
Can I use a hash of fields instead of direct field comparison to simplify comparison of records?

Can I use a hash of fields instead of direct field comparison to simplify comparison of records?


By : VisstPL
Date : March 29 2020, 07:55 AM
With these it helps It is a valid approach. Consider to introduce a calculated field with the hash and index on it.
You may use either CHECKSUM function or write your own hash function like this:
code :
CREATE FUNCTION dbo.GetMyLongHash(@data VARBINARY(MAX))
RETURNS VARBINARY(MAX)
WITH RETURNS NULL ON NULL INPUT
AS
BEGIN
    DECLARE @res VARBINARY(MAX) = 0x
    DECLARE @position INT = 1, @len INT = DATALENGTH(@data)

    WHILE 1 = 1
    BEGIN
        SET @res = @res + HASHBYTES('MD5', SUBSTRING(@data, @position, 8000))
        SET @position = @position+8000
        IF @Position > @len 
          BREAK
    END
    WHILE DATALENGTH(@res) > 16 SET @res= dbo.GetMyLongHash(@res)
    RETURN @res
END
Elasticsearch adding new fields showing Error in Elasticsearch

Elasticsearch adding new fields showing Error in Elasticsearch


By : user285777
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I am using the Elasticsearch JSON Mapping as , I think you need to remove the
code :
"mappings": {
Bonsai elasticsearch vs Amazon elasticsearch price/month comparison?

Bonsai elasticsearch vs Amazon elasticsearch price/month comparison?


By : Sourav Modak
Date : March 29 2020, 07:55 AM
it fixes the issue Bonsai10 is 8 core 1GB memory 10GB disk, limited to 20 shards & 1 million documents.
Amazon's AES doesn't have comparable sizing/pricing. All will be more expensive. If you want 10GB of storage, you could run a single m3.large.elasticsearch (2 core 7.5GB memory, 32GB disk) at US$140/month. If you want 8 cores, single m3.2xlarge.elasticsearch (8 core 30GB memory, 160GB disk) at US$560/month.
Elasticsearch mapping select all fields via template to change their data type Elasticsearch

Elasticsearch mapping select all fields via template to change their data type Elasticsearch


By : Kintan Singh
Date : March 29 2020, 07:55 AM
wish of those help I believe what you are looking for is a dynamic_templates and using path_match instead of match. This demonstrates how that might work:
code :
curl -DELETE localhost:9200/test-*
curl -XDELETE http://localhost:9200/_template/test
curl -XPOST http://localhost:9200/_template/test -d '
{
    "template": "test-*",
    "mappings": {
        "_default_": {
            "dynamic_templates": [
            {
                "level1_level2_all": {
                    "path_match": "level1.level2.*",
                    "match_mapping_type": "*",
                    "mapping": {
                        "index": "not_analyzed",
                        "type": "string"
                    }
                }
            }
            ]
        }
    }
}
'

curl -XPOST http://localhost:9200/test-1/a -d '
{
    "level1": {
        "level2": {
            "x":1
        }
    }
}'
curl -XPOST http://localhost:9200/test-1/a -d '
{
    "level1": {
        "level2": {
            "y":1
        }
    }
}'

curl http://localhost:9200/test-1/_mapping?pretty
  "test-1" : {
    "mappings" : {
      "_default_" : {
        "dynamic_templates" : [ {
          "level1_level2_all" : {
            "mapping" : {
              "index" : "not_analyzed",
              "type" : "string"
            },
            "match_mapping_type" : "*",
            "path_match" : "level1.level2.*"
          }
        } ],
        "properties" : { }
      },
      "a" : {
        "dynamic_templates" : [ {
          "level1_level2_all" : {
            "mapping" : {
              "index" : "not_analyzed",
              "type" : "string"
            },
            "match_mapping_type" : "*",
            "path_match" : "level1.level2.*"
          }
        } ],
        "properties" : {
          "level1" : {
            "properties" : {
              "level2" : {
                "properties" : {
                  "x" : {
                    "type" : "string",
                    "index" : "not_analyzed"
                  },
                  "y" : {
                    "type" : "string",
                    "index" : "not_analyzed"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Filter results by comparison of fields in elasticsearch and kibana

Filter results by comparison of fields in elasticsearch and kibana


By : user2982855
Date : March 29 2020, 07:55 AM
it helps some times I was able to solve this by adding a Scripted Field to my index. To do this, go to Management -> Index Patterns -> select your index -> Scripted fields
Since I needed a boolean output, selected the same as a drop down in Type.
code :
if(doc['fieldA.keyword'].value.toLowerCase().equals(doc['fieldB.keyword'].value.toLowerCase()))
    {
         return true;
    }
    else
    {
         return false;
    }
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org