Elasticsearch 笔记
IK 分词器
跨域配置
yaml
# 跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
禁用 geo 数据库
yaml
ingest.geoip.downloader.enabled: false
GUI
https://github.com/cars10/elasticvue
创建 mapping
sh
PUT http://localhost:9200/index/_mapping
json
{
"properties": {
"content": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
插入示例(自动 ID)
sh
POST http://localhost:9200/index/_doc
Content-Type: application/json
json
{
"content": "这是用于测试的数据"
}
插入或覆盖示例
sh
POST http://localhost:9200/index/_doc/<id>
Content-Type: application/json
json
{
"content": "这是用于测试的数据"
}
检索示例
sh
POST http://localhost:9200/index/_search
json
{
"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