Giter Site home page Giter Site logo

elastic / enterprise-search-python Goto Github PK

View Code? Open in Web Editor NEW
29.0 14.0 24.0 644 KB

Official Python client for Elastic Enterprise Search, App Search, and Workplace Search

Home Page: https://elastic.co/guide/en/enterprise-search-clients/python/current

License: Apache License 2.0

Python 95.46% Dockerfile 0.06% Shell 4.48%
elastic-enterprise-search elastic-app-search elastic-workplace-search python app-search workplace-search enterprise-search appsearch client elasticsearch

enterprise-search-python's Introduction

Elastic Enterprise Search

PyPI Version Supported Python Versions Downloads GitHub Actions Status Buildkite Status

Official Python client for Elastic Enterprise Search, App Search, and Workplace Search

Installation

The package can be installed from PyPI:

$ python -m pip install elastic-enterprise-search

The version follows the Elastic Stack version so 7.11 is compatible with Enterprise Search released in Elastic Stack 7.11.

Documentation

See the documentation for how to get started, compatibility info, configuring, and an API reference.

Contributing

If you'd like to make a contribution to enterprise-search-python we provide contributing documentation to ensure your first contribution goes smoothly.

Feedback 🗣️

The engineering team here at Elastic is looking for developers to participate in research and feedback sessions to learn more about how you use our Python client and what improvements we can make to their design and your workflow. If you're interested in sharing your insights into developer experience and language client design, please fill out this short form. Depending on the number of responses we get, we may either contact you for a 1:1 conversation or a focus group with other developers who use the same client. Thank you in advance - your feedback is crucial to improving the user experience for all Elasticsearch developers!

License

enterprise-search-python is available under the Apache-2.0 license. For more details see LICENSE.

enterprise-search-python's People

Contributors

danielhabenicht avatar joshmock avatar leemthompo avatar picandocodigo avatar pquentin avatar sethmlarson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enterprise-search-python's Issues

Roadmap for 8.0.0

Collecting all the items left to complete before an 8.0.0 release can be created.

  • Switch to new API generator (#100)
  • Deprecate body, params and transport parameters (#108)
  • Change parameters to be keyword-only (#100)
  • enterprise_search.get_stats include parameter serialization (#117)
  • Add new test cases for async clients (#111)
  • Check that a correct version of elastic-transport is installed (#120)
  • Add proper type hints for responses (#123)

Error: {'errors': ['Page must be an object']}

The following code throws the error: elastic_transport.exceptions.BadRequestError: [400] {'errors': ['Page must be an object']}

    resp = app_search.search(
        engine_name=os.environ['ENGINE_NAME'],
        body={
            "query": "test"
        },
        params={
            "page": { "size": 100 }
        }
    )

How should the page.size parameter be passed ?

References:
https://www.elastic.co/guide/en/enterprise-search-clients/python/current/app-search-api.html#app-search-search-apis
https://www.elastic.co/guide/en/app-search/current/search.html

Specifying the `size` parameter for query_suggestion AppSearch method does not work.

I suspect this is at least partially related to #27, but when specifying the size parameter when calling the AppSearch client's query_suggestion method returns an error from AppSearch.
The error returned is

{
  "errors": [
    "Size contains invalid option: must be an integer"
  ]
}

From what I can see, sending the parameters for the request in the request body works, while sending them via the query string doesn't.

UnauthorizationdError

Hi, I followed the following sample code in the main page and got error.

Environment :

  • python 3.8.6
  • enterprise app search 7.10.0b1

Source code:

app_search = EnterpriseSearch(
"https://<...>.ent-search.us-central1.gcp.cloud.es.io",
http_auth="private-",
)

Error code received:
Exception has occurred: UnauthorizedError
[401] {'error': 'unable_to_authenticate_user'}

Bug: `boost` instead of `boosts` in search()

As per elastic app-search api docs, boosts is the correct param.

However in this client, we have boost.
https://github.com/elastic/enterprise-search-python/blob/main/elastic_enterprise_search/_sync/client/app_search.py#L2324

https://github.com/elastic/enterprise-search-python/blob/main/elastic_enterprise_search/_async/client/app_search.py#L2324

and in few other places. This results in the below error.

 line 249, in perform_request
    raise _HTTP_EXCEPTIONS.get(resp.meta.status, ApiError)(
elastic_enterprise_search.exceptions.BadRequestError: [400] {'errors': ['Options contains invalid key: boost']}

Set a default port of 443 when not explicitly given one

Currently if users provide a URL without a port to the Enterprise Search clients they receive the following error:

ValueError: URL must include a 'scheme', 'host', and 'port' component (ie 'https://localhost:9200/')

This has come up a few times internally so no-doubt is happening externally too. Since Enterprise Search's port situation is much less complex than Elasticsearch (which this logic was written for in particular) we should probably make the port value 443 a default to make connecting to instances easier.

Create a release for Elastic Enterprise Search v8.0.0

Hello, what is the timeline for 8.0 release?

I am struggling with connecting to Elastic Cloud using elasticsearch package, but it was easy using enterprise-search-python.

8.0 introduces approximate NN search so we would like to use the newest version.

Thanks!

Indexes are not updating using put_documents

Hi There,

I created a trial account for testing Elastic AppSearch.

I was trying to dump the 5 JSON files stored in my machine. While going through the documentation of put_documents the indexes are not updating and it is showing the number of documents that I dumped for the first time.

If I use indexing_documents in a loop for all the JSON files then the changes are reflecting frequently.

Let me know if I am getting something wrong i.e. the meaning of indexing_documents and put_documents.

Regards
Sanket Sharma

Fix handling of array types in query string

Rails encodes arrays in the URL query string differently than Elasticsearch, found while testing create_engine() to with the source_engines parameter:

from elastic_enterprise_search import AppSearch

app_search = AppSearch()
app_search.create_engine(
    engine_name="test-engine",
    type="meta",
    source_engines=["source-1", "source-2"]
)

encodes in the URL as ?...&source_engines=source-1,source-2
but should encode as ?...&source_engines[]=source-1&source_engines[]=source-2

This will require a change to how elastic-transport-python handles params

Add support to connect with Cloud ID

The Elasticsearch python client can use the Elastic Cloud ID, but looks like for the Enterprise Search python client this is not supported.

Example from the documentation:

from elasticsearch import Elasticsearch

# Password for the 'elastic' user generated by Elasticsearch
ELASTIC_PASSWORD = "<password>"

# Found in the 'Manage Deployment' page
CLOUD_ID = "deployment-name:dXMtZWFzdDQuZ2Nw..."

# Create the client instance
client = Elasticsearch(
    cloud_id=CLOUD_ID,
    basic_auth=("elastic", ELASTIC_PASSWORD)
)

# Successful response!
client.info()
# {'name': 'instance-0000000000', 'cluster_name': ...}

How to use appsearch client for search with precision setting?

Custom precision for search does not work on current version, but somehow runable on older version (7.17.0 ).
I afraid that other part of code would not work as intended if I downgraded the lib. Please help

test = client.search(engine_name="esri-poi-711-location-search",
body={
"query": "acb",
"precision": 2 })

---------------------------------------------------------------------------TypeError Traceback (most recent call last)
Input In [6], in <cell line: 1>()
----> 1 test = client.search(engine_name="esri-poi-711-location-search",
2 body={
3 "query": "acb",
4 "precision": 2 5 })
File ~\miniconda3\lib\site-packages\elastic_enterprise_search_utils.py:454, in _rewrite_parameters..wrapper..wrapped(*args, **kwargs)
451 except KeyError:
452 pass--> 454 return api(*args, **kwargs)
TypeError: search() got an unexpected keyword argument 'precision'

create_curation() method not working in 7.10.0b1

Hi, I'm trying to use the function create_curation() with the parameters engine_name, queries, and promoted_doc_ids as shown below.

app_search.create_curation( engine_name="my-search-engine", queries=["query_1", "query_2"], promoted_doc_ids=["doc_id_1"] )

Which results in the following API request:

POST https://[my-search-domain].ent-search.eastus2.azure.elastic-cloud.com:443/api/as/v1/engines/my-search-engine/curations?queries=query_1%2Cquery_2&promoted=doc_id_1 [status:400 request:0.107s]

I'm getting the message:

HTTP_EXCEPTIONS.get(status, APIError)(message=raw_data, status=status) elastic_transport.exceptions.BadRequestError: [400] {'errors': ['queries must be an array of strings']}

My queries param is a list in Python. I have also tried a tuple. Is this a bug in the client?

Library for release 7.17

Hi

We are preparing to upgrade our server to 7.17. Is there going to be a new release (7.17) for python library?

Rgds and Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.