kibana查询es数据记录
程序员文章站
2022-07-06 09:43:14
...
已经有一段时间没有更新博客信息了,最近刚从北京出差回来,老电脑已经被我放置了快一年的时间没有使用,现在要同步所有的信息到老电脑上去,还好自己对这一套东西也是比较熟悉了
- 询index为test的数据信息
GET test/_search
{
"size": 20,
"query": {
"match_all": {}
}
}
- 查询名为pms,type为product的index的数据信息
GET pms/product/_search
{
"size": 20,
"query": {
"match_all": {}
}
}
- 删除名为test.type为文档类型的index
DELETE test/_doc/*
- 清空test下的所有数据
POST test/_doc/_delete_by_query?refresh&slices=5&pretty
{ "query":
{ "match_all": {} }
}
- 创建名为pms,type为product的index,注意使用的时候需要和我们代码中的实体类的属性类型对应起来,这里我贴出了我的实体类型中的属性
POST pms/product
{
"mappings": {
"properties": {
"id": {
"type": "long"
},
"productSn": {
"type": "long"
},
"brandName": {
"type": "Keyword"
},
"productCategoryId": {
"type": "long"
},
"productCategoryName":{
"type": "Keyword"
},
"pic":{
"type": "Keyword"
},
"name":{
"type": "text"
},
"subTitle": {
"type": "text"
},
"keywords": {
"type": "text"
},
"price": {
"type": "text"
},
"sale": {
"type": "double"
},
"newStatus": {
"type": "integer"
},
"recommandStatus": {
"type": "integer"
},
"stock": {
"type": "integer"
},
"promotionType": {
"type": "integer"
},
"sort": {
"type": "integer"
},
"attrValueList": {
"type": "Nested"
},
"crtTm": {
"type": "date",
"format": "YYYY-MM-dd HH-mm-ss"
}
}
}
}
------------------------------------------------
/**
* 搜索商品的信息
* Created by macro on 2018/6/19.
*/
@Document(indexName = "pms", type = "product",shards = 1,replicas = 0)
public class EsProduct implements Serializable {
private static final long serialVersionUID = -1L;
@Id
private Long id;
@Field(type = FieldType.Keyword)
private String productSn;
private Long brandId;
@Field(type = FieldType.Keyword)
private String brandName;
private Long productCategoryId;
@Field(type = FieldType.Keyword)
private String productCategoryName;
private String pic;
@Field(analyzer = "ik_max_word",type = FieldType.Text)
private String name;
@Field(analyzer = "ik_max_word",type = FieldType.Text)
private String subTitle;
@Field(analyzer = "ik_max_word",type = FieldType.Text)
private String keywords;
private BigDecimal price;
private Integer sale;
private Integer newStatus;
private Integer recommandStatus;
private Integer stock;
private Integer promotionType;
private Integer sort;
@Field(type =FieldType.Nested)
private List<EsProductAttributeValue> attrValueList;
public enum FieldType {
Auto,
Text,
Keyword,
Long,
Integer,
Short,
Byte,
Double,
Float,
Half_Float,
Scaled_Float,
Date,
Date_Nanos,
Boolean,
Binary,
Integer_Range,
Float_Range,
Long_Range,
Double_Range,
Date_Range,
Ip_Range,
Object,
Nested,
Ip,
TokenCount,
Percolator,
Flattened,
Search_As_You_Type;
private FieldType() {
}
}
- 查询index中数据信息的数量
GET test/_count
{
"query": {
"match_all": {}
}
}
- 获取所有索引
GET _all
- 快速创建一个test的index,type为文档类型_doc
PUT test/_doc/1
{
"name": "乔哈哈",
"age": 18,
"birth": "2000-01-01"
}