如何使用正则表达式查询ElasticSearch?

时间:2017-10-09 15:28:51

标签: elasticsearch

我正在为ElasticSearch阅读Reqexp Query但不知何故它对我不起作用。

我想找到任何包含" card"的产品。我的查询是这样的:

SELECT 
`periode_class_members`.`id`, 
`classes`.`id` AS `class`, 
`periode_class_members`.`periode`, 
`user`.`firstname` AS `firstname`, 
`user`.`lastname` AS `lastname`, 
`periode_class_members`.`status`,
min(`periode_class_subjects`.`id`) AS pcs 
FROM `periode_class_subject_members` 
LEFT JOIN `periode_class_members` 
ON periode_class_subject_members.periode_class_member = periode_class_members.id 
RIGHT JOIN `periode_class_subjects` 
ON periode_class_subject_members.periode_class_subject = periode_class_subjects.id 
JOIN `classes` 
ON periode_class_members.class = classes.id 
LEFT JOIN `user` 
ON periode_class_members.user = user.id
where `classes`.`id` = 1
group by `periode_class_members`.`id`, 
`classes`.`id` , 
`periode_class_members`.`periode`, 
`user`.`firstname`, 
`user`.`lastname` , 
`periode_class_members`.`status`;

我点击率为零。知道我在这里缺少什么吗?

1 个答案:

答案 0 :(得分:0)

您在正则表达式中遗漏了.

这应该有效:

{
    "query": {
        "regexp":{
            "product": ".*card.*"
        }
    }
}