最近,公司建立了用户图片,后面构建了es集群,实现了基于标签查询用户使用。 最后一个hive表将被导入到es查询中使用。
之后一定不是用es本机API方式进行查询,所以http方式的查询es怎么样?
首先,我知道es群集的ip地址,默认端口9200。
1 .根据身份准确查询:
http://192.168.100.6033609200/index _ primary _ whole/STD _ index/253 fa 79 b 37709705 b 2086 c 124 CBD 478? pretty
说明: pretty参数显示以json格式显示
2 .根据某字段准确查询:
http://192.168.100.6033609200/index _ primary _ whole/STD _ index/_ search? prettyq=sqid : e a6 d9bc 646673 c 91558 b 9757 c 7a fad 37
说明:用符号链接多个条件
按标签过滤用户
3 .根据某字段准确查询:
http://192.168.100.6033609200/index _ primary _ whole/STD _ index/_ search? pretty-d‘“query”:“term”:“sqid”:“e a6 d9 BC 646673 c 91558 b 9757 c 7a fad 37”}
4 .按字段分组查询:
curl-h‘content-type : application/JSON’- xget‘http://esip 33609200/index _ name/table _ name/_ search? Retty’- d’
{
“大小”:
" aggs " : {
“provinces”:
" terms " : {
字段:「location_prov.keyword
() ) ) ) )。
() ) ) ) )。
() ) ) ) )。
() ) ) ) )。
注意:如果你以前没有相关经验直接咨询,有以下错误。
{
" error " : " content-type header [ application/x-www-form-urlencoded ] is not supported "
“状态”:406
() ) ) ) )。
=========================================================================================
消息内容类型参数: application/x-www-form-urlencoded不支持Json发送。 需要更改为APP/JSON
所以需要追加参数; - h‘content-type : application/JSON '
这里是按省分组的查询结果: