elastic / app-search-python Goto Github PK
View Code? Open in Web Editor NEWElastic App Search Official Python Client
Home Page: https://www.elastic.co/products/app-search
License: Apache License 2.0
Elastic App Search Official Python Client
Home Page: https://www.elastic.co/products/app-search
License: Apache License 2.0
Hi,
I'm trying to upload 260k records, I'm uploading chunks of 100 records but at the 8th chunk I'm getting
Too Many Requests for url: https://host-oft7yr.api.swiftype.com/api/...
How can I change this limitation? Is it their a more optimal way to upload my records?
Steps to reproduce
from elastic_app_search import Client
endpoint = 'yourcoolentsearchcloudendpointhere.io/api/as/v1'
engine_name = 'test'
# Docs: https://github.com/elastic/app-search-python#create-a-signed-search-key
signed_search_key = Client.create_signed_search_key(
'search-xxxxxxxxxxxx',
'search-key',
{'search_fields': { 'description': {}}})
client = Client(
base_endpoint=endpoint,
api_key=signed_search_key,
use_https=True
)
result = client.search(engine_name, 'into')
print (result)
You will get this:
elastic_app_search.exceptions.InvalidCredentials: Unauthorized
And rightly so, because if you were to print the created encoded key you will get something like:
b' eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZWFyY2hfZmllbGRzIjp7ImRlc2NyaXB0aW9uIjp7fX0sImFwaV9rZXlfbmFtZSI6InNlYXJjaC1rZXkifQ.JezVQ4D6L76FadCvplQnCv8QpVJzxqy0dz-i_X4C4s0 '
indicating that this is a byte type value.
Work around
The workaround is to add .decode('utf8')
to the signed_search_key
variable in order to pass the key as a string type value and not a byte type one, like this:
client = Client(
base_endpoint=endpoint,
api_key=signed_search_key.decode('utf8'),
use_https=True
)
And now you will be able to search to your heart's desire.
This doesn't happen on Python 3.3 (our current dependency). But Python 3.3 is already EOL, and ent-search users would rather not have to run EOL code in production in order to use this nifty client.
Cheers!
Hey, I'm not sure if this is a bug, but it was something that really messed up my afternoon. I was unable to get app-search-python to authenticate with a valid API key. The error I was getting is InvalidCredentials: Unauthorized
.
I watched the POST request in Wireshark and discovered that it was sending an entirely different Authentication header. I finally realized that the Requests library was defaulting to my .netrc setting.
From the Requests documentation (emphasis mine).
If no authentication method is given with the auth argument, Requests will attempt to get the authentication credentials for the URL’s hostname from the user’s netrc file. The netrc file overrides raw HTTP authentication headers set with headers=.
So I wonder if we can provide the auth
parameter to Requests to avoid this?
An example of my $HOME/.netrc
file is posted below.
machine localhost
login elastic
password mysecret
Hi, we need to get analytics for a given engine as available on the api https://swiftype.com/documentation/app-search/api/analytics
I have submmited a PR for this functionality:
Cheers
App search allows you to copy a base_url. This includes the protocol e.g.
https://6ddbb728b5014a0eb2bc89a469246231.app-search.us-central1.gcp.cloud.es.io
Other app search clients allow you to use this as the base_url. Having to provide it without https://
seems like a common hurdle users will hit.
The current implementation does not appear to work for self signed certificates.
Proposing to implement the ability to specify to not verify the certificates.
Hi,
Thanks for this great tool.
I miss the method for creating and mantaining curations, especially for bad words when you need to hide all results from the bad words search criteria.
It's tedious to click hide in every document returned by the search criteria.
Has this been considered ?
The python client should have the ability to list, get, create, update and delete synonyms on an engine using the following app search endpoints.
GET /api/as/v1/engines/{ENGINE_NAME}/synonyms
GET /api/as/v1/engines/{ENGINE_NAME}/synonyms/{SYNONYM_SET_ID}
POST /api/as/v1/engines/{ENGINE_NAME}/synonyms
PUT /api/as/v1/engines/{ENGINE_NAME}/synonyms/{SYNONYM_SET_ID}
DELETE /api/as/v1/engines/{ENGINE_NAME}/synonyms/{SYNONYM_SET_ID}
This link is broken:
For more information on keys, check out the [documentation](https://swiftype.com/documentation/app-search/credentials).
I believe it should be:
For more information on keys, check out the [documentation](https://swiftype.com/documentation/app-search/api/credentials).
This link is also broken, but I'm not sure where it should link to:
The `host_identifier` can be found within the [Credentials](https://app.swiftype.com/ascredentials) menu.
In general, should the README continue to direct people to https://app.swiftype.com/as or should it be updated to direct people to the Elastic Cloud hosted version of App Search? For example, host_identifier
doesn't appear to be a thing in the Elastic Cloud version so I found these instructions to be a bit confusing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.