def _default_relevance_score(val: float) -> float:
    return 1 - val
[docs]def check_index_exists(client: RedisType, index_name: str) -> bool:
    """Check if Redis index exists."""
    try:
        client.ft(index_name).info()
    except:  # noqa: E722
        logger.info("Index does not exist")
        return False
    logger.info("Index already exists")
    return True
[docs]class Redis(VectorStore):
    """Wrapper around Redis vector database.
    To use, you should have the ``redis`` python package installed
    and have a running Redis Enterprise or Redis-Stack server
    For production use cases, it is recommended to use Redis Enterprise
    as the scaling, performance, stability and availability is much
    better than Redis-Stack.
    For testing and prototyping, however, this is not required.
    Redis-Stack is available as a docker container the full vector
    search API available.
    .. code-block:: bash
        # to run redis stack in docker locally
        docker run -d -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
    Once running, you can connect to the redis server with the following url schemas:
    - redis://<host>:<port> # simple connection
    - redis://<username>:<password>@<host>:<port> # connection with authentication
    - rediss://<host>:<port> # connection with SSL
    - rediss://<username>:<password>@<host>:<port> # connection with SSL and auth
    Examples:
    The following examples show various ways to use the Redis VectorStore with
    LangChain.
    For all the following examples assume we have the following imports:
    .. code-block:: python