ARRAY_POSITION(expr, val)

    +

    Description

    This function returns the first position of the specified value within the array expression.

    The array position is zero-based; that is, the first position is 0.

    Arguments

    expr

    [Required] The array you want to search.

    val

    [Required] The value whose position you want to know.

    Return Values

    An integer representing the first position of the input val, where the first position is 0. If the value val occurs more than once within the array expr, only the first position is returned.

    It returns -1 if the input val does not exist in the array.

    If one of the arguments is MISSING, it returns MISSING.

    If either of the arguments are non-array values, it returns NULL.

    Example

    Find which position "Brian Kilback" is in the public_likes array.

    SELECT ARRAY_POSITION(t.public_likes, "Brian Kilback") AS array_position
    FROM `travel-sample` t
    WHERE type="hotel"
    LIMIT 1;
    Results
    [
      {
        "array_position": 4
      }
    ]

    Fragments

    These objects, also known as snippets, contain field names that contain an array of one or more text strings.

    The text strings contain the "<mark>" tags surrounding the term that was matched in order to render highlighting.