简体   繁体   中英

ElasticSearch-dsl intervals query

I am using this library to make elastic search queries. It says that it supports intervals query but I can not find a good example that could help me in making my query.

My query is as follows:

GET index/_search
{
  "from": 0,
  "query": {
    "bool": {
      "must": [
        {
          "intervals": {
            "search_field": {
              "all_of": {
                "intervals": [
                  {
                    "match": {
                      "query": "search_term",
                      "max_gaps": 1
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  },
  "size": 50
}


I am trying to make dsl query something like this

Q(
   "bool",
    must=[
          Q("intervals", search_field=search_term, max_gaps=1)
    ]
 )

can someone guide me how to make the proper query or share an example. Thanks

Could try something like this:

s = s.query(
    Q('bool', must=[
        Q('intervals', search_field={
            'all_of': {
                'intervals': [
                    Q('match', query='search_term', max_gaps=1)
                ]
            }
        })
    ])
)

after many tries, it finally worked with this @Adelina thanks for putting me in the right direction!


s = s.query(
    Q('bool', must=[
        Q('intervals', search_field={
            'all_of': {
                'intervals': [
                    {'match': {'query': 'search_term', 'max_gaps': =1}}
                ]
            }
        })
    ])
)


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM