Does field name length matter?

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearch 2.11.1
Debian 12.4

Is there any advantage to short field names? By way of comparison, in MongoDB, field names are stored in each document, so having short field names can save a lot of space. Does it work the same way in OpenSearch?

For the main types of storage in OpenSearch,

  • Inverter index maps term to document id, so filed name’s length doesn’t matter
  • Stored fields is row-based, each document stores the fields names
  • Doc values is column-based, each field name will be stored only once
    , so stored fields will consume too much disk if the length of field name is too large, it’s better to make the field names shorter.

I tried an experiment. I patched up my indexer to let me toggle between long and short field names:

    if (long):
        doc = {'revision_id': row.revision_id,
               'timestamp': row.event_timestamp,
               'comment': human_comment,
               'username': unescape_tnr(row.event_user_text_escaped),
               }
    else:
        doc ={'id': row.revision_id,
              'ts': row.event_timestamp,
              'co': human_comment,
              'un': unescape_tnr(row.event_user_text_escaped),
              }
    yield doc

created two new indexes and inserted the same data into both, except one using the short field names and the other using the long field names. About 2.4 million documents. Total index size ended up 380.5mb vs 387.2mb. So it made a little difference, but probably not enough to worry about. A bit under 2% for this data set.

1 Like