1

I'm trying to have my collection of indexed documents searchable using console input, I get a Serialization error and I don't understand why or how to fix it. I get that it's an error of the type of my variable, but I'm not sure if its giving the wrong type or wants a different type.

searchstr = input("Search for a character \n")

body = {"query": {"prefix" : { "name": { searchstr } } } }

print(es.search(index="sw", doc_type="people", body=body))

Here's the error; elasticsearch.exceptions.SerializationError: ({'query': {'prefix': {'name': {'Lu'}}}}, TypeError("Unable to serialize {'Lu'} (type: <class 'set'>)",))

1 Answer 1

1

I think this is the right way to put prefix query

searchstr = input("Search for a character \n")

body = {"query": {"prefix" : { "value":  searchstr  } } }

print(es.search(index="sw", doc_type="people", body=body))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.