Code Monkey home page Code Monkey logo

app-search-python's People

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  avatar  avatar  avatar  avatar  avatar

Watchers

 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

app-search-python's Issues

Client.create_signed_search_key() returns a byte type value causing signed key searches to fail authentication

Steps to reproduce

  • Have an environment with Python version 3.4 or above.
  • Install app-search-python
  • Try the following script:
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!

Requests defaulting to .netrc

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

Certificate Signing

The current implementation does not appear to work for self signed certificates.
Proposing to implement the ability to specify to not verify the certificates.

No method for managing curations

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 ?

Client should be able to manage synonyms

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}

Broken links in README

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.

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.