簡體   English   中英

ElasticSearch-dsl區間查詢

[英]ElasticSearch-dsl intervals query

我正在使用這個庫進行彈性搜索查詢。 它說它支持intervals查詢,但我找不到可以幫助我進行查詢的好例子。

我的查詢如下:

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


我正在嘗試使 dsl 查詢像這樣

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

可以嘗試這樣的事情:

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

經過多次嘗試,它終於與這個@Adelina 一起工作,謝謝你讓我朝着正確的方向前進!


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


暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM