Class TsidExtractingIdFieldMapper

All Implemented Interfaces:
Iterable<Mapper>, ToXContent, ToXContentFragment

public class TsidExtractingIdFieldMapper extends IdFieldMapper
A mapper for the _id field that builds the _id from the _tsid and @timestamp.
  • Field Details

  • Method Details

    • createField

      public static org.apache.lucene.util.BytesRef createField(DocumentParserContext context, RoutingHashBuilder routingBuilder, org.apache.lucene.util.BytesRef tsid)
    • createId

      public static String createId(int routingHash, org.apache.lucene.util.BytesRef tsid, long timestamp)
    • extractTimestampFromId

      public static long extractTimestampFromId(byte[] id)
    • createId

      public static String createId(boolean dynamicMappersExists, RoutingHashBuilder routingBuilder, org.apache.lucene.util.BytesRef tsid, long timestamp, byte[] suffix)
    • syntheticIdLength

      public static int syntheticIdLength(org.apache.lucene.util.BytesRef tsid)
      Returns the byte length of a synthetic _id for the given tsid.
    • writeSyntheticId

      public static void writeSyntheticId(org.apache.lucene.util.BytesRef tsid, long timestamp, int routingHash, byte[] dest, int destOffset)
      Writes a synthetic _id directly into the destination byte array at the given offset. The synthetic _id has the format: [_tsid + (Long.MAX_VALUE - timestamp) + routing hash].
    • writeSyntheticId

      public static void writeSyntheticId(org.apache.lucene.util.BytesRef tsid, long timestamp, org.apache.lucene.util.BytesRef routingHashBytes, byte[] dest, int destOffset)
      Writes a synthetic _id directly into the destination byte array, using the Uid-encoded routing hash bytes. This avoids decoding/encoding the routing hash through base64 and int conversion. The routingHashBytes are expected to be Uid-encoded (LE bytes, possibly with 0xfd escape prefix).
    • createSyntheticIdBytesRef

      public static org.apache.lucene.util.BytesRef createSyntheticIdBytesRef(org.apache.lucene.util.BytesRef tsid, long timestamp, int routingHash)
    • createSyntheticId

      public static String createSyntheticId(org.apache.lucene.util.BytesRef tsid, long timestamp, int routingHash)
    • extractTimeSeriesIdFromSyntheticId

      public static org.apache.lucene.util.BytesRef extractTimeSeriesIdFromSyntheticId(org.apache.lucene.util.BytesRef id)
    • extractTimestampFromSyntheticId

      public static long extractTimestampFromSyntheticId(org.apache.lucene.util.BytesRef id)
    • extractRoutingHashFromSyntheticId

      public static int extractRoutingHashFromSyntheticId(org.apache.lucene.util.BytesRef id)
      Extract the routing hash value by reading the last 4 bytes of the provided BytesRef representing a UID-encoded synthetic id.
      Parameters:
      id - an array of bytes representing the synthetic _id encoded with Uid.encodeId(java.lang.String).
      Returns:
      the routing hash value as an integer
    • documentDescription

      public String documentDescription(DocumentParserContext context)
      Description copied from class: IdFieldMapper
      Description of the document being parsed used in error messages. Not called unless there is an error.
      Specified by:
      documentDescription in class IdFieldMapper
    • documentDescription

      public String documentDescription(ParsedDocument parsedDocument)
      Description copied from class: IdFieldMapper
      Description of the document being indexed used after parsing for things like version conflicts.
      Specified by:
      documentDescription in class IdFieldMapper
    • reindexId

      public String reindexId(String id)
      Description copied from class: IdFieldMapper
      Build the _id to use on requests reindexing into indices using this _id.
      Specified by:
      reindexId in class IdFieldMapper