简单查询
查询Elasticsearc最简单的办法是使用URI请求查询,这种查询方法简单,但是比较局限,遵循query string查询语法,
语法
curl -XGET 'http://localhost:9200/[index_file_name1,index_file_name2..]/[type_name1,type_name2]/_search?q=field_name:keyword&pretty=true'查询语句
查询指定索引和指定类型下的信息(指定一个index和一个type名)
curl -XGET 'http://localhost:9200/crm/employee/_search?q=first_name:John&pretty=true'搜索邮箱:
curl -XGET 'http://localhost:9200/oa/user/_search?q=email:john@smith.com&pretty=true'搜索子文档里的数据
curl -XGET 'http://localhost:9200/oa/user/_search?q=sex:boy&pretty=true'搜索数组中的数据
curl -XGET 'http://localhost:9200/oa/user/_search?q=interests:dolphins&pretty=true'查询指定索引下素有类型中的信息(指定一个index,没有指定type名)
curl -XGET 'http://localhost:9200/crm/_search?q=first_name:John&pretty=true'查询所有索引中的信息(没有指定index和type名)
curl -XGET 'http://localhost:9200/_search?q=first_name:John&pretty=true'查询多个索引下所有类型中的信息(指定多个index,没有指定type名)
curl -XGET 'http://localhost:9200/crm,oa/_search?q=interests:dolphins&pretty=true'查询所有索引中的信息(指定多个index和多个type名)
curl -XGET 'http://localhost:9200/crm,oa/employee,user/_search?q=interests:dolphins&pretty=true'
注意: 以上内容只是基本查询体。
Last updated
Was this helpful?