Elasticsearch 笔记
IK 分词器
跨域配置
yaml
# 跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"禁用 geo 数据库
yaml
ingest.geoip.downloader.enabled: falseGUI
https://github.com/cars10/elasticvue
创建 mapping
sh
PUT http://localhost:9200/index/_mappingjson
{
"properties": {
"content": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}插入示例(自动 ID)
sh
POST http://localhost:9200/index/_doc
Content-Type: application/jsonjson
{
"content": "这是用于测试的数据"
}插入或覆盖示例
sh
POST http://localhost:9200/index/_doc/<id>
Content-Type: application/jsonjson
{
"content": "这是用于测试的数据"
}检索示例
sh
POST http://localhost:9200/index/_searchjson
{
"query": {
"match": {
"content": "这是用于测"
}
},
"size": 10,
"from": 0,
"sort": []
}json
{
"query": {
"wildcard": {
"content.keyword": "*这是用于测*"
}
},
"size": 10,
"from": 0,
"sort": []
}精确匹配
json
{
"query": {
"bool": {
"filter": {
"term": {
"字段名.keyword": "字段值"
}
}
}
}
}删除示例
sh
DELETE http://localhost:9200/demo