elasticsearch query demo - downgoon/hello-world GitHub Wiki

[root@CDCS-213044189 query]# cat passport_user_request.sh
curl -i -XPOST http://10.213.44.189:10092/passport/user/_search -d '
{
  "query": {
    "bool": {
       "must": [
                 { "wildcard": { "nick": "*zhang*" } },
                 { "match_phrase": { "email": "[email protected]" } }
              ],

       "should": [
                 { "term": { "status": 1  } },
                 { "term": { "status": 0  } }
              ],
       "minimum_should_match": 1

        }
  },

  "sort":[
      {"createtime":"desc"}
  ],

 "size": 5,
 "from": 0
}'
字段 说明
nick 模糊查询
email 精确查询
status 精确过滤
createtime 排序字段
from/size 分页

关于邮箱查询:{ "match_phrase": { "email": "zhangcong1231" } }

这样可以查询:[email protected][email protected]; 也可以以后缀:@qq.com 查询出所有 qq.com 结尾的邮箱。