【问题标题】:Can't translate elasticsearch query into pyes无法将弹性搜索查询转换为 pyes
【发布时间】:2012-04-14 03:43:18
【问题描述】:

我需要您的帮助将查询转换为 pyes。此查询工作正常,问题是我无法使用 pyes 使其工作:

curl -XGET 'http://127.0.0.1:9200/my_index/user/_search?pretty=1' -d '{
    "query" : {
        "bool":{
            "should": [
               { "text": { "first_name": "em" }},
               { "text": { "first_name.partial": "em" }}
             ]
        }
    }
}'

根据0.17 docs,我首先是这样做的:

q1 = TextQuery("first_name","em")
q2 = TextQuery("first_name.partial","em")
q = BoolQuery(should=[q1, q2])
conn.search(q,indices='my_index',doc_types='user')

在出现一些异常后,我意识到我已经安装了 0.16,因为 0.17 是一个不稳定的分支。

那么,简单地说:我怎样才能用 pyes 翻译那个查询?

谢谢!

【问题讨论】:

    标签: python elasticsearch pyes


    【解决方案1】:

    似乎无法将您的查询转换为 pyes 0.16。如您所见,0.16 中的 TextQuery 构造函数没有字段参数:https://github.com/aparo/pyes/blob/109f84696153f3be474e1d7d261776a1bca04570/pyes/query.py#L856,它似乎生成了无效的弹性搜索查询。另一方面,您的代码在 0.17 中应该可以正常工作。

    【讨论】:

      猜你喜欢
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-18
      • 2012-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多