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 协议》,转载必须注明作者和本文链接
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 9

elastucsearch -> ElasticSearch

4年前 评论

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

4年前 评论

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

4年前 评论

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

4年前 评论

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

4年前 评论
幽弥狂

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

4年前 评论

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

4年前 评论

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