es的一些查询操作,供自己查看(日常记录)
GET health_management/_search
{
"query": {
"bool": {
"must": [ //会使用分词器解析(先分析文档,然后通过分析的文档进行查询),term:直接查询精确的
{
"match": {
"fault_description":"齿轮"
}
},
{
"match": {
"fault_name": "轴承" //多条件查询,must相当于sql语句where中的and,should相当于or,must_not
}
}
]
}
}
,//对查询到的数据进行过滤,filter,如范围查询为
"_source":[ "fault_name","fault_description"] //现实的字段名
,
"sort": [
{
"_score": {
"order": "desc" //根据字段排序
}
}
]
,
"from": 0 //分页查询
,
"size": 2 //一页显示几条内容
}
GET _analyze
{
"text": "中华人民共和国"
, "analyzer": "ik_smart"
}
GET _analyze
{
"text": "中华人民共和国"
, "analyzer": "ik_max_word"
}
GET health_management/_search
{
"query": {
"term": {
"model_number" : "a-770"
}
},
"highlight": { //高亮查询highlight
"fields": {
"model_number": {
"pre_tags": "<font color='blue'>",
"post_tags": "</font>"
}
}
}
}