Вопрос

I need your help to translate a query into pyes. This query is working properly, the problem is that I can't use pyes to make it work:

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" }}
             ]
        }
    }
}'

First I was doing this, according to 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')

After a few exceptions raised, i realized that i've installed 0.16, because 0.17 is an unstable branch.

So, to put it simple: How can I translate search that query with pyes?

Thanks!

Это было полезно?

Решение

It doesn't seem to be possible to translate your query into pyes 0.16. As you can see the TextQuery constructor in 0.16 doesn't have the field parameter: https://github.com/aparo/pyes/blob/109f84696153f3be474e1d7d261776a1bca04570/pyes/query.py#L856 and it seem to generate invalid elasticsearch queries. On the other side your code should work fine in 0.17.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top