0

我正在使用 Elasticsearch 2.2 和相应的 python api。我可以像这样查询

res = es.search(index="test-index", body={"query": {"match_all": {}}})

那很好。现在我们还可以使用查询指定一些元参数,如上所示

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_parameters_5

所以基本上,我想执行一个查询

url = 'http://localhost:9200/tesIndex/test/_search?from=%d&q=FieldA=ABC or FieldA=PQR'%start

result =  requests.get(url).json()

我将如何使用 elasticsearch python api 指定此查询?

4

1 回答 1

2

您只需将它们作为关键字参数传递:

res = es.search(index="test-index", body={"query": {"match_all": {}}},  from_=20, size=100, _source=False)

参考:http ://elasticsearch-py.readthedocs.org/en/2.2.0/api.html#elasticsearch.Elasticsearch.search

于 2016-02-08T21:41:42.397 回答