I connected to an elastic search client by using:
es = Elasticsearch(
hosts = myip,
port = myport,
http_auth = (myname, mycode),
connection_class = RequestsHttpConnection,
scheme = 'https',
use_ssl = True,
verify_certs = False,
)
Now i want ta start making queries like these:
es.search(index="sw", body={"query": {"prefix" : { "name" : "Mary" }}})
But the problem is that i do not know the names of the fields that are in elastic. How can i print the data from elastic or better, print the names of the headers?
CodePudding user response:
I would suggest you check out Kibana, as it provides an easy to use UI into Elasticsearch that lets you explore that data that is stored there
otherwise you might want to look at the mappings of the index, that will give you field names (there is no such thing as headers in Elasticsearch language)
CodePudding user response:
I managed to print the available indexes of elastic with the command below:
def print_indices(es):
print(es.indices.get_alias("*"))
Then i got all the data by executing the below query:
query = {"query": {
"multi_match": {
"query" : "*",
"type" : "cross_fields",
"fields" : ["*"],
}
}
}
However, i got the following message:
field expansion matches too many fields, limit: 1024, got: 5233')
I don't know how to extend the limit, i guess for smaller databases i works just fine.