hashdiff icon indicating copy to clipboard operation
hashdiff copied to clipboard

Issues with diff

Open cdenneen opened this issue 5 years ago • 0 comments

Tried with 1.0.0 release and below is against master branch:

script

require 'awesome_print'
require 'hashdiff'
a = {"order"=>1, "index_patterns"=>["logstash-cloudtrail*"], "settings"=>{"index"=>{"lifecycle"=>{"name"=>"logging_policy", "rollover_alias"=>"logstash-cloudtrail-write"}, "routing"=>{"allocation"=>{"require"=>{"node_type"=>"hot"}}}, "mapping"=>{"total_fields"=>{"limit"=>8000}, "ignore_malformed"=>"true"}, "refresh_interval"=>"30s", "number_of_shards"=>2, "merge"=>{"scheduler"=>{"max_thread_count"=>1}}, "number_of_replicas"=>2}}, "mappings"=>{"_doc"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "mapping"=>{"norms"=>false, "type"=>"text"}, "match_mapping_type"=>"string"}}, {"string_fields"=>{"mapping"=>{"norms"=>false, "type"=>"text", "fields"=>{"keyword"=>{"ignore_above"=>256, "type"=>"keyword"}}}, "match_mapping_type"=>"string", "match"=>"*"}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}}}}, "aliases"=>{"all_logs"=>{}}}

b = {"order"=>1, "aliases"=>{"all_logs"=>{}}, "mappings"=>{"_doc"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"norms"=>false, "type"=>"text"}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}}}}, "index_patterns"=>["logstash-cloudtrail*"], "settings"=>{"index"=>{"mapping.total_fields.limit"=>8000, "mapping.ignore_malformed"=>true, "routing.allocation.require.node_type"=>"hot", "refresh_interval"=>"30s", "merge.scheduler.max_thread_count"=>1, "number_of_replicas"=>2, "number_of_shards"=>2, "lifecycle.rollover_alias"=>"logstash-cloudtrail-write", "lifecycle.name"=>"logging_policy"}}}
ap Hashdiff.diff(a,b)

result

[
  [0] [
    [0] "-",
    [1] "settings.index.lifecycle",
    [2] {
                "name" => "logging_policy",
      "rollover_alias" => "logstash-cloudtrail-write"
    }
  ],
  [1] [
    [0] "-",
    [1] "settings.index.mapping",
    [2] {
      "ignore_malformed" => "true",
          "total_fields" => {
        "limit" => 8000
      }
    }
  ],
  [2] [
    [0] "-",
    [1] "settings.index.merge",
    [2] {
      "scheduler" => {
        "max_thread_count" => 1
      }
    }
  ],
  [3] [
    [0] "-",
    [1] "settings.index.routing",
    [2] {
      "allocation" => {
        "require" => {
          "node_type" => "hot"
        }
      }
    }
  ],
  [4] [
    [0] "+",
    [1] "settings.index.lifecycle.name",
    [2] "logging_policy"
  ],
  [5] [
    [0] "+",
    [1] "settings.index.lifecycle.rollover_alias",
    [2] "logstash-cloudtrail-write"
  ],
  [6] [
    [0] "+",
    [1] "settings.index.mapping.ignore_malformed",
    [2] true
  ],
  [7] [
    [0] "+",
    [1] "settings.index.mapping.total_fields.limit",
    [2] 8000
  ],
  [8] [
    [0] "+",
    [1] "settings.index.merge.scheduler.max_thread_count",
    [2] 1
  ],
  [9] [
    [0] "+",
    [1] "settings.index.routing.allocation.require.node_type",
    [2] "hot"
  ]
]

If you look at the source the true is already a Boolean so not sure why the diff for ignore_malformed shows a "true" to true. The rest of the diff appears to be exactly the same so not sure why this is causing a diff.

cdenneen avatar Feb 12 '20 02:02 cdenneen