<commit_before>.. _api:

API Documentation
=================

.. py:module:: walrus

.. autoclass:: Database(Redis)
    :members:
      __init__,
      run_script,
      get_temp_key,
      __iter__,
      search,
      get_key,
      cache,
      lock,
      List,
      Hash,
      Set,
      ZSet,
      HyperLogLog,
      Array,
      listener,
      stream_log

Container types
---------------

.. autoclass:: Container
    :members:


.. autoclass:: Hash(Container)
    :members:
      __getitem__,
      __setitem__,
      __delitem__,
      __contains__,
      __len__,
      __iter__,
      search,
      keys,
      values,
      items,
      update,
      as_dict,
      incr

.. autoclass:: List(Container)
    :members:
      __getitem__,
      __setitem__,
      __delitem__,
      __len__,
      __iter__,
      append,
      prepend,
      extend,
      insert_before,
      insert_after,
      popleft,
      popright

.. autoclass:: Set(Container)
    :members:
      add,
      __delitem__,
      remove,
      pop,
      __contains__,
      __len__,
      __iter__,
      search,
      members,
      random,
      __sub__,
      __or__,
      __and__,
      diffstore,
      interstore,
      unionstore

.. autoclass:: ZSet(Container)
    :members:
      add,
      __getitem__,
      __setitem__,
      __delitem__,
      remove,
      __contains__,
      __len__,
      __iter__,
      search,
      score,
      rank,
      count,
      lex_count,
      range,
      range_by_score,
      range_by_lex,
      remove_by_rank,
      remove_by_score,
      remove_by_lex,
      incr,
      interstore,
      unionstore

.. autoclass:: HyperLogLog(Container)
    :members:
      add,
      __len__,
      merge

.. autoclass:: Array(Container)
    :members:
      __getitem__,
      __setitem__,
      __delitem__,
      __len__,
      append,
      extend,
      pop,
      __contains__,
      __iter__

High-level APIs
---------------

.. autoclass:: Cache
    :members:
      __init__,
      get,
      set,
      delete,
      keys,
      flush,
      incr,
      cached,
      cached_property,
      cache_async

.. autoclass:: Lock
    :members:
      __init__,
      acquire,
      release,
      clear

.. autoclass:: Model
    :members:
      __init__,
      to_hash,
      create,
      all,
      query,
      get,
      load,
      delete,
      save

Field types
-----------

.. autoclass:: Field
    :members:
      __init__,
      get_indexes

.. autoclass:: TextField
    :members:

    .. py:method:: search(query[, default_conjunction='and'])

        :param str query: Search query.
        :param str default_conjunction: Either ``'and'`` or ``'or'``.

        Create an expression corresponding to the given search query. Search queries can contain conjunctions (``AND`` and ``OR``).

        Example:

        .. code-block:: python

            class Message(Model):
                database = my_db
                content = TextField(fts=True)

            expression = Message.content.search('python AND (redis OR walrus)')
            messages = Message.query(expression)
            for message in messages:
                print message.content

.. autoclass:: IntegerField
    :members:

.. autoclass:: AutoIncrementField(IntegerField)
    :members:

.. autoclass:: FloatField
    :members:

.. autoclass:: ByteField
    :members:

.. autoclass:: BooleanField
    :members:

.. autoclass:: UUIDField
    :members:

.. autoclass:: DateTimeField
    :members:

.. autoclass:: DateField
    :members:

.. autoclass:: JSONField
    :members:

Container Field Types
^^^^^^^^^^^^^^^^^^^^^

.. autoclass:: HashField
    :members:

.. autoclass:: ListField
    :members:

.. autoclass:: SetField
    :members:

.. autoclass:: ZSetField
    :members:
<commit_msg>Add autocomplete to the api docs.<commit_after>.. _api:

API Documentation
=================

.. py:module:: walrus

.. autoclass:: Database(Redis)
    :members:
      __init__,
      run_script,
      get_temp_key,
      __iter__,
      search,
      get_key,
      cache,
      lock,
      List,
      Hash,
      Set,
      ZSet,
      HyperLogLog,
      Array,
      listener,
      stream_log

Container types
---------------

.. autoclass:: Container
    :members:


.. autoclass:: Hash(Container)
    :members:
      __getitem__,
      __setitem__,
      __delitem__,
      __contains__,
      __len__,
      __iter__,
      search,
      keys,
      values,
      items,
      update,
      as_dict,
      incr

.. autoclass:: List(Container)
    :members:
      __getitem__,
      __setitem__,
      __delitem__,
      __len__,
      __iter__,
      append,
      prepend,
      extend,
      insert_before,
      insert_after,
      popleft,
      popright

.. autoclass:: Set(Container)
    :members:
      add,
      __delitem__,
      remove,
      pop,
      __contains__,
      __len__,
      __iter__,
      search,
      members,
      random,
      __sub__,
      __or__,
      __and__,
      diffstore,
      interstore,
      unionstore

.. autoclass:: ZSet(Container)
    :members:
      add,
      __getitem__,
      __setitem__,
      __delitem__,
      remove,
      __contains__,
      __len__,
      __iter__,
      search,
      score,
      rank,
      count,
      lex_count,
      range,
      range_by_score,
      range_by_lex,
      remove_by_rank,
      remove_by_score,
      remove_by_lex,
      incr,
      interstore,
      unionstore

.. autoclass:: HyperLogLog(Container)
    :members:
      add,
      __len__,
      merge

.. autoclass:: Array(Container)
    :members:
      __getitem__,
      __setitem__,
      __delitem__,
      __len__,
      append,
      extend,
      pop,
      __contains__,
      __iter__

High-level APIs
---------------

.. autoclass:: Autocomplete
    :members:
      __init__,
      store,
      search,
      exists,
      boost_object,
      remove,
      flush

.. autoclass:: Cache
    :members:
      __init__,
      get,
      set,
      delete,
      keys,
      flush,
      incr,
      cached,
      cached_property,
      cache_async

.. autoclass:: Lock
    :members:
      __init__,
      acquire,
      release,
      clear

.. autoclass:: Model
    :members:
      __init__,
      to_hash,
      create,
      all,
      query,
      get,
      load,
      delete,
      save

Field types
-----------

.. autoclass:: Field
    :members:
      __init__,
      get_indexes

.. autoclass:: TextField
    :members:

    .. py:method:: search(query[, default_conjunction='and'])

        :param str query: Search query.
        :param str default_conjunction: Either ``'and'`` or ``'or'``.

        Create an expression corresponding to the given search query. Search queries can contain conjunctions (``AND`` and ``OR``).

        Example:

        .. code-block:: python

            class Message(Model):
                database = my_db
                content = TextField(fts=True)

            expression = Message.content.search('python AND (redis OR walrus)')
            messages = Message.query(expression)
            for message in messages:
                print message.content

.. autoclass:: IntegerField
    :members:

.. autoclass:: AutoIncrementField(IntegerField)
    :members:

.. autoclass:: FloatField
    :members:

.. autoclass:: ByteField
    :members:

.. autoclass:: BooleanField
    :members:

.. autoclass:: UUIDField
    :members:

.. autoclass:: DateTimeField
    :members:

.. autoclass:: DateField
    :members:

.. autoclass:: JSONField
    :members:

Container Field Types
^^^^^^^^^^^^^^^^^^^^^

.. autoclass:: HashField
    :members:

.. autoclass:: ListField
    :members:

.. autoclass:: SetField
    :members:

.. autoclass:: ZSetField
    :members:

{'fraction_non_alphanumeric': 0.11484053497942387, 'fraction_numerical': 0.0, 'mean_word_length': 1.7259025587101298, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '287875', 'n_tokens_mistral': 2436, 'n_tokens_neox': 2341, 'n_words': 543}