Skip to main content
Use LPOS to find the position of an element in a list. The scan starts at the head and, by default, reports the index of the first match or null when there is none. RANK selects which match to report: RANK 2 skips to the second occurrence, and a negative rank searches backwards from the tail, so RANK -1 finds the last occurrence. COUNT returns that many matching indexes instead of just one, and COUNT 0 returns all of them. MAXLEN limits how many elements are compared, which bounds the cost of the search on a long list at the price of possibly missing matches beyond that point. It is the read-only way to locate a value before acting on it with LSET or LREM.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Related topics

LPOSLPOP