6.7. 创建商品索引

本教程最新版为 8.x,当前版本已放弃维护,请阅读最新版本!

创建商品索引

上一节我们学习了 Elasticsearch 类库在 Laravel 项目中的基础使用方法,接下来我们创建一个新的 Elasticsearch 索引用以存放商品数据,以供之后的搜索使用。

1. 创建索引

现在我们需要重新创建一个 Elasticsearch 索引用于保存商品数据,名为 products

$ curl -XPUT http://localhost:9200/products?pretty

接下来定义商品字段:

$ 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": {...

本文章首发在 LearnKu.com 网站上。

为了保证课程的高品质,我们需要对课程进行收费。付费后 才能观看剩余内容。 购买

上一篇 下一篇
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 7

holashatu
这个_version 字段有什么意义么
1 个点赞 | 1 个回复 | 问答 | 课程版本 5.5
AMA32
求教大佬 Windows+Homestead 如何使用 Kibana?
0 个点赞 | 4 个回复 | 问答 | 课程版本 5.5
AmberLavigne
strip_tags 函数 引起 商品描述 description 的 img 标签也被删除
0 个点赞 | 3 个回复 | 问答 | 课程版本 5.5
KunHong
创建商品索引
0 个点赞 | 1 个回复 | 问答 | 课程版本 7.x
KunHong
创建商品索引
0 个点赞 | 1 个回复 | 问答 | 课程版本 7.x