AnySearch is a Elasticsearch and OpenSearch compatibility library. It provides utility functions for smoothing over the differences between the Python libraries with the goal of writing Python code that is compatible on both (including the *search and *search-dsl packages).
See the documentation for more information on what is provided.
Documentation
Documentation is available on Read the Docs.
Prerequisites
Python 3.6, 3.7, 3.8, 3.9 and 3.10.
Installation
Install latest stable version from PyPI:
pip install anysearch
or latest stable version from GitHub:
pip install https://github.com/barseghyanartur/anysearch/archive/main.tar.gz
Configuration
AnySearch automatically detects whether you use Elasticsearch or OpenSearch by looking at which packages are installed. However, if you have both packages installed, you can instruct AnySearch which one do you actually want to use. The way to do that is to set the ANYSEARCH_PREFERRED_BACKEND environment variable to either Elasticsearch or OpenSearch.
For Elasticsearch:
import os
os.environ.setdefault("ANYSEARCH_PREFERRED_BACKEND", "Elasticsearch")
For OpenSearch:
import os
os.environ.setdefault("ANYSEARCH_PREFERRED_BACKEND", "OpenSearch")
Usage
elasticsearch/opensearch
How-to
With elasticsearch you would do:
from elasticsearch import Connection, Elasticsearch
With opensearch you would do:
from opensearch_py import Connection, OpenSearch
With anysearch you would change that to:
from anysearch.search import Connection, AnySearch
elasticsearch-dsl/opensearch-dsl
How-to
With elasticsearch-dsl you would do:
from elasticsearch_dsl import AggsProxy, connections, Keyword
from elasticsearch_dsl.document import Document
With opensearch-dsl you would do:
from opensearch_dsl import AggsProxy, connections, Keyword
from opensearch_dsl.document import Document
With anysearch you would change that to:
from anysearch.search_dsl import AggsProxy, connections, Keyword
from anysearch.search_dsl.document import Document
Testing
Project is covered with tests.
To test with all supported Python versions type:
tox
To test against specific environment, type:
tox -e py39
To test just your working environment type:
pytest
To run a single test in your working environment type:
pytest test_anysearch.py
To run a single test class in a given test module in your working environment type:
pytest test_anysearch.py::AnySearchTestCase
It’s assumed that you have either elasticsearch-dsl or opensearch-dsl installed. If not, install the requirements first.
Writing documentation
Keep the following hierarchy.
=====
title
=====
header
======
sub-header
----------
sub-sub-header
~~~~~~~~~~~~~~
sub-sub-sub-header
^^^^^^^^^^^^^^^^^^
sub-sub-sub-sub-header
++++++++++++++++++++++
sub-sub-sub-sub-sub-header
**************************
License
MIT
Support
For any security issues contact me at the e-mail given in the Author section. For overall issues, go to GitHub.
Metadata
Release files for anysearch 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| anysearch-0.2.2.tar.gz | 13.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| anysearch-0.2.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 21.9 kB
Release files / anysearch-0.2.2.tar.gz
| Download URL | anysearch-0.2.2.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62a7d1cae2b9822e2ec262f5108c4bdd6c159e8b53adbae7fc29885451e1b722
|
|
BLAKE2b-256 checksum How to use checksums |
46d64d228ad60e92113ad9edfb6dbb81e269840cedb6fa7f9949693c7af8844e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.16
|
Release files / anysearch-0.2.2-py2.py3-none-any.whl
| Download URL | anysearch-0.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e0538d8f138258692a568e305ffaf4bd565959993fe4d1a2513fedf7d35f95da
|
|
BLAKE2b-256 checksum How to use checksums |
eb699b1d928f717c859b81d7c138d1a668544dded59202afd919c31fea9f2175
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.16
|