<commit_before>Migrating From ``pyes``
=======================

Moving your project from ``pyes`` to ``pyelasticsearch`` is an easy process,
particularly for most simple use cases. This page lists a couple code changes
that may be necessary to complete your upgrade.

* ``pyelasticsearch`` requires ``requests`` to be version 1.x. Breaking
  changes were introduced into ``requests``, so if your project was
  previously using 0.x, you may need to update your code (most likely change
  ``response.json`` to ``response.json()``)

* Instantiating the client should be as simple as changing the invocation::

    pyes.ES(host, **kwargs)

  to::

    pyelasticsearch.ElasticSearch(host, **kwargs)

* ``pyelasticsearch`` has no method ``create_index_if_missing``. Instead,
  you'll need catch the exception manually::

    try:
        connection.create_index(index='already_existing_index')
    except pyelasticsearch.ElasticHttpError as ex:
        if not ex.error.startswith('IndexAlreadyExistsException'):
            raise

* Instead of using ``pyes``'s ``_send_request``, you'll want to use
  :py:meth:`pyelasticsearch.ElasticSearch.send_request`. This also requires the
  path to be passed as an iterable instead of a string. For example::

    es._send_request('POST', 'my_index/my_doc_type', body)

  would become::

    connection.send_request('POST', ['my_index', 'my_doc_type'], body)

* If using the ``indices`` keyword argument in ``pyes``, the
  ``pyelasticsearch`` analog is the ``index`` keyword argument.

* If using the ``doc_types`` keyword argument in ``pyes``, the
  ``pyelasticsearch`` analog is the ``doc_type`` keyword argument.

* :py:meth:`pyelasticsearch.ElasticSearch.get` will raise a
  :class:`pyelasticsearch.exceptions.ElasticHttpNotFoundError` exception if
  no results are found.
<commit_msg>docs: Update index creation example<commit_after>Migrating From ``pyes``
=======================

Moving your project from ``pyes`` to ``pyelasticsearch`` is an easy process,
particularly for most simple use cases. This page lists a couple code changes
that may be necessary to complete your upgrade.

* ``pyelasticsearch`` requires ``requests`` to be version 1.x. Breaking
  changes were introduced into ``requests``, so if your project was
  previously using 0.x, you may need to update your code (most likely change
  ``response.json`` to ``response.json()``)

* Instantiating the client should be as simple as changing the invocation::

    pyes.ES(host, **kwargs)

  to::

    pyelasticsearch.ElasticSearch(host, **kwargs)

* ``pyelasticsearch`` has no method ``create_index_if_missing``. Instead,
  you'll need catch the exception manually::

    try:
        connection.create_index(index='already_existing_index')
    except pyelasticsearch.ElasticIndexAlreadyExistsError as ex:
        print 'Index already exists, moving on...'

* Instead of using ``pyes``'s ``_send_request``, you'll want to use
  :py:meth:`pyelasticsearch.ElasticSearch.send_request`. This also requires the
  path to be passed as an iterable instead of a string. For example::

    es._send_request('POST', 'my_index/my_doc_type', body)

  would become::

    connection.send_request('POST', ['my_index', 'my_doc_type'], body)

* If using the ``indices`` keyword argument in ``pyes``, the
  ``pyelasticsearch`` analog is the ``index`` keyword argument.

* If using the ``doc_types`` keyword argument in ``pyes``, the
  ``pyelasticsearch`` analog is the ``doc_type`` keyword argument.

* :py:meth:`pyelasticsearch.ElasticSearch.get` will raise a
  :class:`pyelasticsearch.exceptions.ElasticHttpNotFoundError` exception if
  no results are found.

{'fraction_non_alphanumeric': 0.12171052631578948, 'fraction_numerical': 0.0010964912280701754, 'mean_word_length': 4.866559485530547, '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': '3674961', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1010, 'n_words': 378}