橡皮、老虎皮、狮子皮哪一个最不好?

select * from a where name = "XXX" and age =1 or age =2

Elasticsearch | 作者 wanglei1988 | 发布于2018年07月19日 | 阅读数:2878

这种结构的查询,特别后面的and age =1 or age =2 怎么用javaAPi实现
已邀请:

strglee

赞同来自:

方案1:
{
"query": {
"bool": {
"must": [
{
"term": {
"name": "xxx"
}
},
{
"terms": {
"age": [
1,
2
]
}
}
]
}
}
}
方案二:
{
"query": {
"bool": {
"must": [
{
"term": {
"name": "xxx"
}
}
],
"should": [
{
"term": {
"age": 1
}
},
{
"term": {
"age": 2
}
}
],
"minimum_should_match": 1
}
}
}

wanglei1988

赞同来自:

兄弟,谢谢了!

wanglei1988

赞同来自:

知道了,谢谢

要回复问题请先登录注册