Elasticsearch
版本:7.0以上
基本操作
查询所有索引: get _cat/indices
查询某个索引的字段 :get gs-recommend-v2/_mappings
新建索引
例如:
put /gs-recommend-v2
{
"mappings": {
"properties": {
"_update": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"child_count": {
"type": "float"
},
"collection_count": {
"type": "float"
},
"comment_rating": {
"type": "float"
},
"commentcount": {
"type": "float"
},
"commentcount_within_1year": {
"type": "float"
},
"districtid": {
"type": "keyword"
},
"districtpath": {
"type": "text"
},
"officialpoiid": {
"type": "keyword"
},
"parentdistrictid": {
"type": "keyword"
},
"poiscore": {
"type": "float"
},
"price": {
"type": "float"
},
"recallscore": {
"type": "float"
},
"share_count": {
"type": "float"
},
"sight_rank": {
"type": "float"
},
"sortno": {
"type": "float"
},
"t_score_no_add": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"total_picnum": {
"type": "float"
},
"totalsales": {
"type": "float"
},
"uv_section": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"uvsum": {
"type": "float"
},
"feature": {
"type": "dense_vector",
"dims": 13
}
}
}
}检索数据
全局检索
条件检索
向量检索
删除索引和数据
删除索引:Delete 索引名称1,索引名称2
根据匹配条件删除数据
删除所有数据
Python操作ES
安装elasticsearch包:pip install elasticsearch
查询ES里的所有数据
删除满足条件的数据
Java操作ES
BoolQuery 的用法与特性
BoolQuery 作为一个主要的Query结构一般用于整个Query的根。Query的结果会根据score默认排序
BoolQuery 拥有4个不同的Query类型。
默认的排序是按照score来进行的。我们也可以自己添加用来排序的键。
当搜索请求中包含sort时,搜索结果中会包含sortValues。例如以上sort的结果中,每一个hit会有如下Array
参考资料
【最佳实践】阿里云 Elasticsearch 向量检索4步搭建“以图搜图”搜索引擎
Last updated
Was this helpful?