【问题标题】:How to specify meta parameters in search query如何在搜索查询中指定元参数
【发布时间】:2016-02-09 05:44:23
【问题描述】:

我正在使用 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 指定此查询?

【问题讨论】:

    标签: python elasticsearch-2.0


    【解决方案1】:

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

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-27
      • 2013-04-08
      • 2015-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-20
      相关资源
      最近更新 更多