用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
[TOC] ## index(索引) ### 新建简单索引 ``` curl -X PUT 'localhost:9200/weather' ``` 返回 ``` { "acknowledged":true, "shards_acknowledged":true } ``` ### 新建 mapping 索引 ``` cutl -X PUT http://localhost:9200/videoinfo { "mappings": { "video": { "properties": { "name": { "type": "text" }, "cat_id": { "type": "integer" } } } } } ``` > 在 `videoinfo`索引中新建`video`type(表) ### 新建中文分词设置索引 `./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.1/elasticsearch-analysis-ik-5.5.1.zip` > 上面代码安装的是5.5.1版的插件,与 Elastic 5.5.1 配合使用。 凡是需要搜索的中文字段,都要单独设置一下 demo ``` curl -X PUT 'localhost:9200/accounts' -d ' { "mappings": { "person": { "properties": { "user": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" }, "title": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" }, "desc": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" } } } } }' //======== search_analyzer是搜索词的分词器。 ik_max_word分词器是插件ik提供的,可以对文本进行最大数量的分词 ``` > 首先新建一个名称为accounts的 Index,里面有一个名称为person的 Type。person有三个字段 > 这三个字段都是中文,而且类型都是文本(text),所以需要指定中文分词器,不能使用默认的英文分词器 ## 删索引 `curl -X DELETE 'localhost:9200/weather'`