podhmo / dictknife

armyknife of handling dict object
MIT License
19 stars 4 forks source link

mkdict with array #70

Closed podhmo closed 6 years ago

podhmo commented 6 years ago

e.g.

{
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "jobId": [
              "5bd280d5493ad70001dda105",
              "5bd280b7493ad70001dda100",
              "5bd1b0fc493ad70001dd94a3",
              "5bd184e5493ad70001dd948c",
              "5bd17f60493ad70001dd9439",
              "5bd17f05493ad70001dd940c",
              "5bd16d32493ad70001dd93dd",
              "5bd16d32493ad70001dd93e2",
              "5bd16b6f493ad70001dd93c4",
              "5bd16aba493ad70001dd93a3"
            ]
          }
        }
      ]
    }
  },
  "size": 1000
}
podhmo commented 6 years ago

hey,

dictknife mkdict xs/0 1 xs/1 3 xs/2 5
{
  "xs": [
    1,
    3,
    5
  ]
}
dictknife mkdict xs/ 1 xs/ 3 xs/ 5
{
  "xs": [
    1,
    3,
    5
  ]
}
dictknife mkdict xs/-1 1 xs/-1 3 xs/-1 5
{
  "xs": {
    "-1": 5
  }
}
podhmo commented 6 years ago

so,

$ dictknife mkdict \
query/bool/must/0/terms/jobId/ 5bd280d5493ad70001dda105 \
query/bool/must/0/terms/jobId/ 5bd280b7493ad70001dda100 \
query/bool/must/0/terms/jobId/ 5bd1b0fc493ad70001dd94a3 \
query/bool/must/0/terms/jobId/ 5bd184e5493ad70001dd948c \
size 1000
{
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "jobId": [
              "5bd280d5493ad70001dda105",
              "5bd280b7493ad70001dda100",
              "5bd1b0fc493ad70001dd94a3",
              "5bd184e5493ad70001dd948c"
            ]
          }
        }
      ]
    }
  },
  "size": 1000
}