(a like '%aa%' or b like '%bb%') and age>20 请问下这个怎么写查询
Elasticsearch | 作者 qq731761942 | 发布于2018年02月26日 | 阅读数:2923
SELECT *
FROM users
WHERE
(a like '%aa%' or b like '%bb%') and age>20
请问下这个怎么写查询,最好用是php api
我现在的写法是这样的,但是结果会把大于1519453400的所有数据列出来,又不包含关键词!!!!
$params = [
"from" => $from, // how long between scroll requests. should be small!
"size" => $pagesize,
'index' => '*',
'body' => [
'query' => [
'bool' => [
'should' => [
[ 'match' => [ 'title' => $kw ] ],
[ 'match' => [ 'discription' => $kw ] ],
[ 'match' => [ 'url' => $kw ] ],
],
"filter" => [
"range" => ["updatetime" => ["gte" => "1519453400"]],
]
]
],
'highlight' => [
// 'pre_tags' => ["<em>"], // not required
// 'post_tags' => ["</em>"], // not required
'fields' => [
'*' => new \stdClass(),
],
'require_field_match' => true
]
]
];
FROM users
WHERE
(a like '%aa%' or b like '%bb%') and age>20
请问下这个怎么写查询,最好用是php api
我现在的写法是这样的,但是结果会把大于1519453400的所有数据列出来,又不包含关键词!!!!
$params = [
"from" => $from, // how long between scroll requests. should be small!
"size" => $pagesize,
'index' => '*',
'body' => [
'query' => [
'bool' => [
'should' => [
[ 'match' => [ 'title' => $kw ] ],
[ 'match' => [ 'discription' => $kw ] ],
[ 'match' => [ 'url' => $kw ] ],
],
"filter" => [
"range" => ["updatetime" => ["gte" => "1519453400"]],
]
]
],
'highlight' => [
// 'pre_tags' => ["<em>"], // not required
// 'post_tags' => ["</em>"], // not required
'fields' => [
'*' => new \stdClass(),
],
'require_field_match' => true
]
]
];
3 个回复
strglee
赞同来自: qq731761942
hufuman
赞同来自:
装一个这个插件,可以把sql转成dsl
hufuman
赞同来自:
装一个这个插件,可以把sql转成dsl