Elasticsearch 一些命令汇总 以及学习总结
es 一些记录 以及学习总结
1 安装IK 分词
/usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.0/elasticsearch-analysis-ik-6.4.0.zip
注意:要指定对应的es版本的分词插件
2 创建索引 相当于创建数据库
curl -XPUT http://localhost:9200/products?pretty
3 建立索引文档 类似数据的字段吧
curl -H'Content-Type: application/json' -XPUT http://localhost:9200/products/_mapping/_doc?pretty -d'{
"properties": {
"type": { "type": "keyword" } ,
"title": { "type": "text", "analyzer": "ik_smart" },
"long_title": { "type": "text", "analyzer": "ik_smart" },
"category_id": { "type": "integer" },
"category": { "type": "keyword" },
"category_path": { "type": "keyword" },
"description": { "type": "text", "analyzer": "ik_smart" },
"price": { "type": "scaled_float", "scaling_factor": 100 },
"on_sale": { "type": "boolean" },
"rating": { "type": "float" },
"sold_count": { "type": "integer" },
"review_count": { "type": "integer" },
"skus": {
"type": "nested",
"properties": {
"title": { "type": "text", "analyzer": "ik_smart", "copy_to": "skus_title" },
"description": { "type": "text", "analyzer": "ik_smart", "copy_to": "skus_description" },
"price": { "type": "scaled_float", "scaling_factor": 100 }
}
},
"properties": {
"type": "nested",
"properties": {
"name": { "type": "keyword" },
"value": { "type": "keyword", "copy_to": "properties_value" },
"search_value": { "type": "keyword" }
}
}
}
}'
注意事项:
1 nested 代表创建复杂数据
2 copy_to 主要做查询的特定映射的数据
本作品采用《CC 协议》,转载必须注明作者和本文链接
elastucsearch -> ElasticSearch
@crazy 哈哈这个玩意太难打了
@Krisji 要严谨...
现在已经默认支持中文分词了?
@BradStevens 嗯好像是啊。可是我的并没有 很怪异
@Krisji 我不知道哈,记得5.x的时候不带中文分词,不知道现在了,不支持的话,估计要安装额外的中文分词插件了
然而中文分词并不好用。。。
请问查看所有的索引和删除某个索引的命令是啥?在某度上一只没搜到。
@lianglunzhong 删除是delete