使用 man ascii 来查看 ASCII 表。

(a like '%aa%' or b like '%bb%') and age>20 请问下这个怎么写查询

Elasticsearch | 作者 qq731761942 | 发布于2018年02月26日 | 阅读数:2545

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
        ]
]
];  
已邀请:

strglee

赞同来自: qq731761942

'query' => [
'bool' => [
'should' => [
[ 'match' => [ 'title' => $kw ] ],
[ 'match' => [ 'discription' => $kw ] ],
[ 'match' => [ 'url' => $kw ] ],
],
"minimum_should_match": 1, //should条件至少满足一个
"filter" => [
"range" => ["updatetime" => ["gte" => "1519453400"]],
]
]
],

hufuman

赞同来自:

https://github.com/NLPchina/elasticsearch-sql

装一个这个插件,可以把sql转成dsl

hufuman

赞同来自:

https://github.com/NLPchina/elasticsearch-sql

装一个这个插件,可以把sql转成dsl

要回复问题请先登录注册