[7.x] Update all rST :: to code-block directives
This commit is contained in:
+12
-4
@@ -30,7 +30,9 @@ elasticsearch returns a 2XX response. Otherwise an instance of
|
||||
raised. You can see other exception and error states in :ref:`exceptions`. If
|
||||
you do not wish an exception to be raised you can always pass in an ``ignore``
|
||||
parameter with either a single status code that should be ignored or a list of
|
||||
them::
|
||||
them:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
es = Elasticsearch()
|
||||
@@ -49,7 +51,9 @@ Global timeout can be set when constructing the client (see
|
||||
:class:`~elasticsearch.Connection`'s ``timeout`` parameter) or on a per-request
|
||||
basis using ``request_timeout`` (float value in seconds) as part of any API
|
||||
call, this value will get passed to the ``perform_request`` method of the
|
||||
connection class::
|
||||
connection class:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# only wait for 1 second, regardless of the client's default
|
||||
es.cluster.health(wait_for_status='yellow', request_timeout=1)
|
||||
@@ -84,12 +88,16 @@ Response Filtering
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``filter_path`` parameter is used to reduce the response returned by
|
||||
elasticsearch. For example, to only return ``_id`` and ``_type``, do::
|
||||
elasticsearch. For example, to only return ``_id`` and ``_type``, do:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
es.search(index='test-index', filter_path=['hits.hits._id', 'hits.hits._type'])
|
||||
|
||||
It also supports the ``*`` wildcard character to match any field or part of a
|
||||
field's name::
|
||||
field's name:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
es.search(index='test-index', filter_path=['hits.hits._*'])
|
||||
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ if not on_rtd: # only import and set the theme if we're building docs locally
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ["_static"]
|
||||
# html_static_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
|
||||
+3
-1
@@ -49,7 +49,9 @@ If you have complex SSL logic for connecting to Elasticsearch using an `SSLConte
|
||||
might be more helpful. You can create one natively using the python SSL library with the
|
||||
`create_default_context` (https://docs.python.org/3/library/ssl.html#ssl.create_default_context) method.
|
||||
|
||||
To create an `SSLContext` object you only need to use one of cafile, capath or cadata::
|
||||
To create an `SSLContext` object you only need to use one of cafile, capath or cadata:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> from ssl import create_default_context
|
||||
>>> context = create_default_context(cafile=None, capath=None, cadata=None)
|
||||
|
||||
+27
-10
@@ -10,12 +10,16 @@ Installation
|
||||
------------
|
||||
|
||||
Install the ``elasticsearch`` package with `pip
|
||||
<https://pypi.org/project/elasticsearch>`_::
|
||||
<https://pypi.org/project/elasticsearch>`_:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ python -m pip install elasticsearch
|
||||
|
||||
If your application uses async/await in Python you can install with
|
||||
the ``async`` extra::
|
||||
the ``async`` extra:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ python -m pip install elasticsearch[async]
|
||||
|
||||
@@ -41,7 +45,9 @@ For **Elasticsearch 2.0** and later, use the major version 2 (``2.x.y``) of the
|
||||
library, and so on.
|
||||
|
||||
The recommended way to set your requirements in your `setup.py` or
|
||||
`requirements.txt` is::
|
||||
`requirements.txt` is:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Elasticsearch 7.x
|
||||
elasticsearch>=7.0.0,<8.0.0
|
||||
@@ -62,7 +68,7 @@ versions are also released as ``elasticsearch2``, ``elasticsearch5`` and ``elast
|
||||
Example Usage
|
||||
-------------
|
||||
|
||||
::
|
||||
.. code-block:: python
|
||||
|
||||
from datetime import datetime
|
||||
from elasticsearch import Elasticsearch
|
||||
@@ -177,7 +183,9 @@ location.
|
||||
|
||||
By default we allow ``urllib3`` to open up to 10 connections to each node, if
|
||||
your application calls for more parallelism, use the ``maxsize`` parameter to
|
||||
raise the limit::
|
||||
raise the limit:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# allow up to 25 connections to each node
|
||||
es = Elasticsearch(["host1", "host2"], maxsize=25)
|
||||
@@ -194,7 +202,9 @@ SSL and Authentication
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can configure the client to use ``SSL`` for connecting to your
|
||||
elasticsearch cluster, including certificate verification and HTTP auth::
|
||||
elasticsearch cluster, including certificate verification and HTTP auth:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
@@ -308,7 +318,9 @@ your configuration this might be something you don't want or break completely.
|
||||
In some environments (notably on Google App Engine) your HTTP requests might be
|
||||
restricted so that ``GET`` requests won't accept body. In that case use the
|
||||
``send_get_body_as`` parameter of :class:`~elasticsearch.Transport` to send all
|
||||
bodies via post::
|
||||
bodies via post:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
es = Elasticsearch(send_get_body_as='POST')
|
||||
@@ -318,7 +330,8 @@ Compression
|
||||
When using capacity-constrained networks (low throughput), it may be handy to enable
|
||||
compression. This is especially useful when doing bulk loads or inserting large
|
||||
documents. This will configure compression.
|
||||
::
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
es = Elasticsearch(hosts, http_compress=True)
|
||||
@@ -329,7 +342,9 @@ Running on AWS with IAM
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you want to use this client with IAM based authentication on AWS you can use
|
||||
the `requests-aws4auth`_ package::
|
||||
the `requests-aws4auth`_ package:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from elasticsearch import Elasticsearch, RequestsHttpConnection
|
||||
from requests_aws4auth import AWS4Auth
|
||||
@@ -355,7 +370,9 @@ Custom serializers
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
By default, `JSONSerializer`_ is used to encode all outgoing requests.
|
||||
However, you can implement your own custom serializer::
|
||||
However, you can implement your own custom serializer
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from elasticsearch.serializer import JSONSerializer
|
||||
|
||||
|
||||
+3
-1
@@ -9,7 +9,9 @@ it to the constructor of :class:`~elasticsearch.Elasticsearch` as
|
||||
:class:`~elasticsearch.connection.RequestsHttpConnection` requires ``requests``
|
||||
to be installed.
|
||||
|
||||
For example to use the ``requests``-based connection just import it and use it::
|
||||
For example to use the ``requests``-based connection just import it and use it:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from elasticsearch import Elasticsearch, RequestsHttpConnection
|
||||
es = Elasticsearch(connection_class=RequestsHttpConnection)
|
||||
|
||||
Reference in New Issue
Block a user