Class RandomDocumentPicks

java.lang.Object
org.elasticsearch.ingest.RandomDocumentPicks

public final class RandomDocumentPicks extends Object
  • Method Details

    • randomFieldName

      public static String randomFieldName(Random random)
      Returns a random field name. Can be a leaf field name or the path to refer to a field name using the dot notation.
    • randomLeafFieldName

      public static String randomLeafFieldName(Random random)
      Returns a random leaf field name.
    • randomExistingFieldName

      public static String randomExistingFieldName(Random random, IngestDocument ingestDocument)
      Returns a randomly selected existing field name out of the fields that are contained in the document provided as an argument. Does not return the _version field unless it is the only field.
    • addRandomField

      public static String addRandomField(Random random, IngestDocument ingestDocument, Object value)
      Adds a random non existing field to the provided document and associates it with the provided value. The field will be added at a random position within the document, not necessarily at the top level using a leaf field name.
    • canAddField

      public static boolean canAddField(String path, IngestDocument ingestDocument)
      Checks whether the provided field name can be safely added to the provided document. When the provided field name holds the path using the dot notation, we have to make sure that each node of the tree either doesn't exist or is a map, otherwise new fields cannot be added.
    • randomIngestDocument

      public static IngestDocument randomIngestDocument(Random random)
      Generates a random document and random metadata
    • randomIngestDocument

      public static IngestDocument randomIngestDocument(Random random, Map<String,Object> source)
      Generates a document that holds random metadata and the document provided as a map argument
    • randomSource

      public static Map<String,Object> randomSource(Random random)
    • randomFieldValue

      public static Object randomFieldValue(Random random)
      Generates a random field value, can be a string, a number, a list of an object itself.
    • randomString

      public static String randomString(Random random)