Skip to content

Change output of _cat/fielddata to be row-centric #10249

Closed

Description

@drewr

Currently _cat/fielddata adds a column per field:

id                     host        ip         node          total title disambiguation 
lFPaYAUQTUGKOIKiRYZOeg hotel.local 10.0.1.200 raphael          0b    0b             0b 
qfsKN3rAQ0q9Ef1eUF-fvA hotel.local 10.0.1.200 splinter         0b    0b             0b 
djZlGw6qQcGBNCqW5iFoIA hotel.local 10.0.1.200 michaelangelo 9.7kb 8.2kb          1.4kb 
OsBOGm9UQFypK10Kx4r99A hotel.local 10.0.1.200 donatello        0b    0b             0b 
3YEw8s0KTTaLrn3HVNkXCg hotel.local 10.0.1.200 leonardo         0b    0b             0b 

which isn't really the spirit of the cat api. In order to find out how many fields are in the cache on michaelangelo, eg, you'd have to count the columns. In order to sort the fields in descending order by bytes, you'd have to do some significant processing (read: something more than counting some lines) outside the api, rather than just a ?bytes=b | sort -rnk999.

I propose something like:

id                     host        ip         node          field           size
lFPaYAUQTUGKOIKiRYZOeg hotel.local 10.0.1.200 raphael       total             0b
djZlGw6qQcGBNCqW5iFoIA hotel.local 10.0.1.200 michaelangelo total          9.7kb
djZlGw6qQcGBNCqW5iFoIA hotel.local 10.0.1.200 michaelangelo title          8.2kb
djZlGw6qQcGBNCqW5iFoIA hotel.local 10.0.1.200 michaelangelo disambiguation 1.4kb

Then you can ask questions like:

curl -s 'localhost:9200/_cat/fielddata?h=node,field,size&bytes=b' | fgrep -v ' total' | sort -rnk3 | head

to get a snapshot of the biggest offenders and where they live. This denormalization is the heart of the API, like with segments and shards.

Activity

  1. added
    :Core/Infra/CAT APIs
    on Mar 25, 2015
  2. added this to the 2.0 milestone on Mar 25, 2015
  3. removed this from the 2.0 milestone on Mar 25, 2015
  4. added
    good first issue
    on Mar 25, 2015
  5. nirmalc commented on Apr 8, 2015

    @nirmalc
    Contributor

    Also filtering by fields by url param might be good addition

  6. szroland commented on Jun 17, 2015

    @szroland
    Contributor

    What if you have a field called total or have total in the name? Is it a good idea to mix the aggregate size with individual field sizes in the same table?

    Maybe there could be a flag that would allow you to switch between totals or individual fields:

    _cat/fielddata
    
    id                     host        ip         node          field           size
    djZlGw6qQcGBNCqW5iFoIA hotel.local 10.0.1.200 michaelangelo title          8.2kb
    djZlGw6qQcGBNCqW5iFoIA hotel.local 10.0.1.200 michaelangelo disambiguation 1.4kb
    

    But if you want totals:

    _cat/fielddata?sum
    
    id                     host        ip         node          size
    lFPaYAUQTUGKOIKiRYZOeg hotel.local 10.0.1.200 raphael       0b
    djZlGw6qQcGBNCqW5iFoIA hotel.local 10.0.1.200 michaelangelo 9.7kb
    
  7. szroland commented on Jun 21, 2015

    @szroland
    Contributor

    I created a pull request that implements this behavior, see just above. Instead of the idea I described previously, it seemed cleaner to use _cat/fielddata for totals, and _cat/fielddata/{fields] for field level details.

    E.g.:

    curl '192.168.56.10:9200/_cat/fielddata'

    id                     host    ip            node          total
    c223lARiSGeezlbrcugAYQ myhost1 10.20.100.200 Jessica Jones 385.6kb
    waPCbitNQaCL6xC8VxjAwg myhost2 10.20.100.201 Adversary     435.2kb
    yaDkp-G3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 Microchip     284.6kb
    

    Whereas if you want field-level data, you can do either
    curl '192.168.56.10:9200/_cat/fielddata?fields=body,text' or
    curl '192.168.56.10:9200/_cat/fielddata/*' to get:

    id                     host    ip            node          total   field size
    c223lARiSGeezlbrcugAYQ myhost1 10.20.100.200 Jessica Jones 385.6kb body  159.8kb
    c223lARiSGeezlbrcugAYQ myhost1 10.20.100.200 Jessica Jones 385.6kb text  225.7kb
    waPCbitNQaCL6xC8VxjAwg myhost2 10.20.100.201 Adversary     435.2kb body  159.8kb
    waPCbitNQaCL6xC8VxjAwg myhost2 10.20.100.201 Adversary     435.2kb text  275.3kb
    yaDkp-G3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 Microchip     284.6kb body  109.2kb
    yaDkp-G3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 Microchip     284.6kb text  175.3kb
    

    Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Core/Infra/CAT APIs>breakinggood first issuehelp wantedv5.0.0-alpha3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions