【发布时间】:2016-05-06 23:00:11
【问题描述】:
我正在尝试使用 elasticsearch 查询 DSL 编写下面提到的 SQL 查询,但我无法获得与 SQL 查询相同的结果。任何人都可以帮助 e 处理下面提到的案例的 bool 查询。我使用的是 elasticsearch 2.1.1 版本。
id.eq(someId)
.and(
(anotherId.eq(another).and(node.eq(node)))
.or
(domain.in(List))
)
这是我尝试过的。如果这是正确的,我如何在 Java DSL 中编写相同的查询?
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"id": 1
}
}
]
}
},
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"anotherId": "ss"
}
},
{
"term": {
"node": "ss"
}
}
]
}
},
{
"bool": {
"must": [
{
"terms": {
"domain" : [ "cc", "cc" ]
}
}
]
}
}
]
}
}
}
}
}
【问题讨论】:
-
您能否编辑您的问题并添加您目前尝试过的 ES 查询?否则,文档 (elastic.co/guide/en/elasticsearch/guide/current/…) 很好地解释了如何将 SQL 查询转换为 ES 查询。
-
@Mihali:我已经相应地更新了问题。
标签: elasticsearch