簡體   English   中英

Elasticsearch遷移過濾器

[英]Elasticsearch migration filter

這是我的問題:我需要將我的過濾器/查詢語法(elasticsearch 1.x)轉換為elasticsearch 5.x語法。

這是我的查詢:

{
"query ": {
    "filtered ": {
        "query ": {
            "fuzzy_like_this ": {
                "like_text ": "    cin ",
                "max_query_terms ": 12,
                "fuzziness ": 0.7
            }
        },
        "filter ": {
            "and ": {
                "filters ": [{
                    "or ": {
                        "filters ": [{
                            "type ": {
                                "value ": "etude_patrimoine_architecture "
                            }
                        }]
                    }
                }]
            }
        }
    }
}
}

我不太了解bool的彈性5.x語法。

遷移此過濾器的任何幫助將不勝感激。

基本上,

  • filtered/query部分進入bool/must
  • filtered/filter部分可以是bool/filterbool/must_notbool/should取決於您是否需要AND,NOT或OR行為。

這樣的事情應該讓您入門:

{
  "query": {
    "bool": {
      "must": [
         query
      ],
      "should": [
         queryLayers
      ]
    }
  }
}

這是最終的解決方案:

{
    "query": {
        "bool": {
            "must": [{
                "match": {
                    "_all": {
                        "query": QUERYVALUE,
                        "fuzziness": "AUTO"
                    }
                }
            }, {
                "bool": {
                    "should": [{
                        "type": {
                            "value": VAL1
                        }
                    }, {
                        "type": {
                            "value": VAL2
                        }
                    }]
                }
            }],
            "filter": {
                "geo_shape": {
                    "geometry": {
                        "shape": {
                            "type": "envelope",
                            "coordinates": COORDARAY
                        }
                    }
                }
            }
        }
    }
}

暫無
暫無

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

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