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 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 9

elastucsearch -> ElasticSearch

4年前 评论

@crazy 哈哈这个玩意太难打了

4年前 评论

现在已经默认支持中文分词了?

4年前 评论

@BradStevens 嗯好像是啊。可是我的并没有 很怪异

4年前 评论

@Krisji 我不知道哈,记得5.x的时候不带中文分词,不知道现在了,不支持的话,估计要安装额外的中文分词插件了

4年前 评论
幽弥狂

然而中文分词并不好用。。。

4年前 评论

请问查看所有的索引和删除某个索引的命令是啥?在某度上一只没搜到。

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!