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 "
}
}]
}
}]
}
}
}
}
}
我真的不明白 elastic 5.x 布尔语法。
如能帮助迁移此过滤器,我们将不胜感激。
基本上,
filtered/query
部分进入 bool/must
filtered/filter
部分在 bool/filter
、bool/must_not
或 bool/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
}
}
}
}
}
}
}
这是我的问题:我需要将我的过滤器/查询语法 (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 "
}
}]
}
}]
}
}
}
}
}
我真的不明白 elastic 5.x 布尔语法。
如能帮助迁移此过滤器,我们将不胜感激。
基本上,
filtered/query
部分进入bool/must
filtered/filter
部分在bool/filter
、bool/must_not
或bool/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
}
}
}
}
}
}
}