当前位置: 首页 > news >正文

自主建网站seo品牌

自主建网站,seo品牌,网页布局设计摘要,揭阳网页制作docker 安装elastic search 、 kibana(可视化管理elastic search) docker pull elasticsearch:7.12.1 docker pull kibana:7.12.1创建docker自定义网络 docker自定义网络可以使得容器之间使用容器名网络互连,默认的网络不会有这功能。 一定…

docker 安装elastic search 、 kibana(可视化管理elastic search)

docker pull elasticsearch:7.12.1
docker pull kibana:7.12.1

 

创建docker自定义网络

docker自定义网络可以使得容器之间使用容器名网络互连,默认的网络不会有这功能。
一定要配置自定义网络,并将两个容器同时加到网络中,否则下面的http://es:9200会无法访问到es

docker network create es-net

 

启动elastic search、kibana容器

启动elastic search容器

docker run -d \--name es \-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \-e "discovery.type=single-node" \-v es-data:/usr/share/elasticsearch/data \-v es-plugins:/usr/share/elasticsearch/plugins \--privileged \--network es-net \-p 9200:9200 \-p 9300:9300 \
elasticsearch:7.12.1

访问 http://192.168.137.139:9200 (注意换成自己服务器的ip地址)
在这里插入图片描述

启动kibana容器

docker run -d \
--name kibana \
-e ELASTICSEARCH_HOSTS=http://es:9200 \
--network=es-net \
-p 5601:5601  \
kibana:7.12.1

访问 http://192.168.137.139:5601 (注意换成自己服务器的ip地址)
在这里插入图片描述
 

给es安装 ik分词器

默认的分词器对中文并不友好,ik分词器可以更好的支持中文分词
下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v7.12.1
(官方有其他的下载方式,可以参考:https://github.com/medcl/elasticsearch-analysis-ik)
在这里插入图片描述

 查看es-plugins的挂载卷所在目录
docker volume inspect es-plugins

得到 /var/lib/docker/volumes/es-plugins/_data

将下载的文件解压缩并传到服务器挂在卷中

scp -r ik myserver:/var/lib/docker/volumes/es-plugins/_data

在这里插入图片描述

重启es服务

docker restart esocker logs es | grep ik	# 查看ik分词器是否成功加载

在这里插入图片描述
使用Dev Tools测试
在这里插入图片描述

IK分词器包含两种模式:(根据业务选择)

  • ik_smart:最少切分

  • ik_max_word:最细切分

扩展ik分词器的词典

在这里插入图片描述
奥里给并没有组成一个词

cd /var/lib/docker/volumes/es-plugins/_data/ik/config/

oligei.dic文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties><comment>IK Analyzer 扩展配置</comment><!--用户可以在这里配置自己的扩展字典 --><entry key="ext_dict"></entry><entry key="ext_dict">my_dict.dic</entry><!--用户可以在这里配置自己的扩展停止词字典--><entry key="ext_stopwords"></entry><entry key="ext_stopwords">my_stopwords.dic</entry><!--用户可以在这里配置远程扩展字典 --><!-- <entry key="remote_ext_dict">words_location</entry> --><!--用户可以在这里配置远程扩展停止词字典--><!-- <entry key="remote_ext_stopwords">words_location</entry> -->
</properties>

重启es 和 kibana

docker restart es
docker restart kibanaocker logs es | grep my_ # 查看日志是否加载了配置

在这里插入图片描述
在这里插入图片描述

 


 

es 索引库操作

创建索引库

PUT /user 
{"mappings": {"properties": {"info": {"type": "text","analyzer": "ik_smart"},"email": {"type": "keyword","index": "false"},"name": {"type": "object","properties": {"fistName": {"type": "keyword"},"lastName": {"type": "keyword"}}}}}
}

删除索引库

DELETE /user

修改索引库

索引库不支持修改已有的属性,但可以增加属性

PUT /user/_mapping
{"properties": {"age": {"type": "integer"}}
}

查询索引库

GET /user

 


 

es 文档操作

新增文档

POST /user/_doc/1
{"info": "学习使我快乐","email": "xxx@qq.com","age": "18","name": {"firstName": "code","lastName": "horse"}
}

删除文档

DELETE /user/_doc/1

修改文档

全量修改:先删除,后新建(如果没有,也会新建)

PUT /user/_doc/1
{"info": "学习使我快乐222222222222222","email": "xxx@qq.com","age": "18","name": {"firstName": "code","lastName": "horse"}
}

增量修改:只修改指定字段的值

POST /user/_update/1
{"doc": {"info": "学习使我快乐333333333333"}
}

查询文档

GET /user/_doc/1

 


 

Java使用ES (RestAPI)

官方使用文档:https://www.elastic.co/guide/en/elasticsearch/client/index.html
在这里插入图片描述
本教程使用的是 Migrating from the High Level Rest Client

导入依赖

pom.xml


<!--FastJson  官方需要的other dependencies-->
<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.71</version>
</dependency>

springboot依赖管理有可能会给你导入的依赖版本会给覆盖掉
在这里插入图片描述
解决方案:覆盖springboot的版本

<properties><elasticsearch.version>7.12.1</elasticsearch.version>
</properties>

在这里插入图片描述

操作索引库

IndexDatabaseTest.java

public class IndexDatabaseTest {private RestHighLevelClient client;@BeforeEachpublic void setUp() {  // 创建es连接this.client = new RestHighLevelClient(RestClient.builder(HttpHost.create("http://192.168.137.139:9200")));}@Testpublic void clientStatus() {    // 查看是否连接成功System.out.println(client);}// 创建索引库@Testpublic void createIndexDataBase() throws IOException {CreateIndexRequest request = new CreateIndexRequest("user");String createIndexDataBaseDSL = "{\n" +"  \"mappings\": {\n" +"    \"properties\": {\n" +"      \"info\": {\n" +"        \"type\": \"text\",\n" +"        \"analyzer\": \"ik_smart\"\n" +"      },\n" +"      \"email\": {\n" +"        \"type\": \"keyword\",\n" +"        \"index\": \"false\"\n" +"      },\n" +"      \"name\": {\n" +"        \"type\": \"object\",\n" +"        \"properties\": {\n" +"          \"fistName\": {\n" +"            \"type\": \"keyword\"\n" +"          },\n" +"          \"lastName\": {\n" +"            \"type\": \"keyword\"\n" +"          }\n" +"        }\n" +"      }\n" +"    }\n" +"  }\n" +"}";request.source(createIndexDataBaseDSL, XContentType.JSON);client.indices().create(request, RequestOptions.DEFAULT);}// 删除索引库@Testpublic void deleteIndexDataBase() throws IOException {DeleteIndexRequest request = new DeleteIndexRequest("user");client.indices().delete(request, RequestOptions.DEFAULT);}// 修改索引库(只支持增加mapping)@Testpublic void updateIndexDataBase() throws IOException {PutMappingRequest request = new PutMappingRequest("user");request.source("{\n" +"  \"properties\": {\n" +"    \"age\": {\n" +"      \"type\": \"integer\"\n" +"    }\n" +"  }\n" +"}\n", XContentType.JSON);client.indices().putMapping(request, RequestOptions.DEFAULT);}// 查找索引库@Testpublic void getIndexDataBase() throws IOException {GetIndexRequest request = new GetIndexRequest("user");GetIndexResponse getIndexResponse = client.indices().get(request, RequestOptions.DEFAULT);Map<String, MappingMetadata> mappings = getIndexResponse.getMappings();System.out.println(mappings.get("user").sourceAsMap().values());}@AfterEachpublic void unMount() throws IOException { 	// 断开es连接this.client.close();}}

 

操作文档

DocTest.java

public class DocTest {private RestHighLevelClient client;@BeforeEachvoid setUp() {  // 创建es连接this.client = new RestHighLevelClient(RestClient.builder(HttpHost.create("http://192.168.137.139:9200")));}@Testpublic void clientStatus() {    // 查看是否连接成功System.out.println(client);}// 创建文档@Testpublic void createIndexDataBase() throws IOException {IndexRequest request = new IndexRequest("user").id("1");String createDocDSL = "{\n" +"  \"info\": \"学习使我快乐\",\n" +"  \"email\": \"xxx@qq.com\",\n" +"  \"name\": {\n" +"    \"firstName\": \"code\",\n" +"    \"lastName\": \"horse\"\n" +"  }\n" +"}";request.source(createDocDSL,XContentType.JSON);client.index(request, RequestOptions.DEFAULT);}// 删除文档@Testpublic void deleteIndexDataBase() throws IOException {DeleteRequest request = new DeleteRequest("user", "1");client.delete(request, RequestOptions.DEFAULT);}// 修改文档 (API实现的是全量修改)@Testpublic void updateIndexDataBase() throws IOException {UpdateRequest request = new UpdateRequest("user", "1");request.doc("{\n" +"    \"info\": \"学习使我痛苦!!!!!!!\"\n" +"  }", XContentType.JSON);client.update(request, RequestOptions.DEFAULT);}// 查找文档@Testpublic void getIndexDataBase() throws IOException {GetRequest request = new GetRequest("user", "1");GetResponse response = client.get(request, RequestOptions.DEFAULT);String json = response.getSourceAsString();System.out.println(json);}@Testprivate Map<String, Object> getData(String text) {Map<String, Object> map = new HashMap<>();map.put("info", text);map.put("email", text + "@qq.com");Map<String, String> name = new HashMap<>();name.put("firstName", text);name.put("lastName", text);map.put("name", name);System.out.println(JSON.toJSONString(map));return map;}// 批量导入文档@Testpublic void testBulk() throws IOException {BulkRequest request = new BulkRequest();for (int i = 1; i <= 200; i ++ ) {String text = String.valueOf(i);Map<String, Object> data = getData(text);request.add(new IndexRequest("user").id(text).source(JSON.toJSONString(data), XContentType.JSON));}client.bulk(request, RequestOptions.DEFAULT);}@AfterEachpublic void unMount() throws IOException { // 断开es连接this.client.close();}
}

文章转载自:
http://dinncoabsord.ydfr.cn
http://dinncobusinesslike.ydfr.cn
http://dinncoforeword.ydfr.cn
http://dinncopooch.ydfr.cn
http://dinncogeanticlinal.ydfr.cn
http://dinnconogging.ydfr.cn
http://dinncooverwrap.ydfr.cn
http://dinncowoodcutter.ydfr.cn
http://dinncomolech.ydfr.cn
http://dinncoreplicable.ydfr.cn
http://dinncomanger.ydfr.cn
http://dinncoconfesser.ydfr.cn
http://dinncodullard.ydfr.cn
http://dinncomegalith.ydfr.cn
http://dinncohafnium.ydfr.cn
http://dinncoshall.ydfr.cn
http://dinncoaramean.ydfr.cn
http://dinncofoundrous.ydfr.cn
http://dinncocatfoot.ydfr.cn
http://dinncocorruptionist.ydfr.cn
http://dinncocolleen.ydfr.cn
http://dinncopuddingheaded.ydfr.cn
http://dinncoviscoelastic.ydfr.cn
http://dinncopuzzleheaded.ydfr.cn
http://dinncoinobservantness.ydfr.cn
http://dinncoabsurdity.ydfr.cn
http://dinncobetamethasone.ydfr.cn
http://dinncoboswell.ydfr.cn
http://dinncoupholstery.ydfr.cn
http://dinncodhtml.ydfr.cn
http://dinncobroken.ydfr.cn
http://dinncomonied.ydfr.cn
http://dinncopermease.ydfr.cn
http://dinncofomes.ydfr.cn
http://dinncomonogenism.ydfr.cn
http://dinncosnarly.ydfr.cn
http://dinncoillusage.ydfr.cn
http://dinncodrinker.ydfr.cn
http://dinncofluorochrome.ydfr.cn
http://dinncoparadichlorobenzene.ydfr.cn
http://dinncoglobate.ydfr.cn
http://dinncoshrubby.ydfr.cn
http://dinncolivraison.ydfr.cn
http://dinncojizz.ydfr.cn
http://dinncocacodaemon.ydfr.cn
http://dinncotwiggery.ydfr.cn
http://dinncotumbledung.ydfr.cn
http://dinncomonaker.ydfr.cn
http://dinncowelfare.ydfr.cn
http://dinncometasomatosis.ydfr.cn
http://dinncolaocoon.ydfr.cn
http://dinncointraday.ydfr.cn
http://dinncoenfeeblement.ydfr.cn
http://dinncotranquillo.ydfr.cn
http://dinncopicturephone.ydfr.cn
http://dinncoorgasm.ydfr.cn
http://dinncotapper.ydfr.cn
http://dinncothickleaf.ydfr.cn
http://dinncoorganule.ydfr.cn
http://dinncofederalization.ydfr.cn
http://dinncomineralogical.ydfr.cn
http://dinncoelephantiac.ydfr.cn
http://dinncocorpus.ydfr.cn
http://dinncokraurotic.ydfr.cn
http://dinncolacewing.ydfr.cn
http://dinncoadvertise.ydfr.cn
http://dinncohydrolyse.ydfr.cn
http://dinncounderemphasize.ydfr.cn
http://dinncoarrowwood.ydfr.cn
http://dinncoyellowtop.ydfr.cn
http://dinncomicroprobe.ydfr.cn
http://dinncoinkslinger.ydfr.cn
http://dinncoroyston.ydfr.cn
http://dinncoretrench.ydfr.cn
http://dinncoantiserum.ydfr.cn
http://dinncocalculability.ydfr.cn
http://dinncomentalism.ydfr.cn
http://dinncoglycine.ydfr.cn
http://dinncoamerica.ydfr.cn
http://dinncoceinture.ydfr.cn
http://dinncoboater.ydfr.cn
http://dinncomanipur.ydfr.cn
http://dinncobobbery.ydfr.cn
http://dinncometafile.ydfr.cn
http://dinncotechnics.ydfr.cn
http://dinncomauretania.ydfr.cn
http://dinncoequilateral.ydfr.cn
http://dinncopannage.ydfr.cn
http://dinncosacrilegiousness.ydfr.cn
http://dinncohunk.ydfr.cn
http://dinncoineloquent.ydfr.cn
http://dinncoinsessorial.ydfr.cn
http://dinncoharvestman.ydfr.cn
http://dinncotullibee.ydfr.cn
http://dinncofootage.ydfr.cn
http://dinncoaltissimo.ydfr.cn
http://dinncofiligreed.ydfr.cn
http://dinncosnowbrush.ydfr.cn
http://dinncotrevira.ydfr.cn
http://dinncotourniquet.ydfr.cn
http://www.dinnco.com/news/106226.html

相关文章:

  • app开发制作网站平台网店培训教程
  • 做网站 做手机app要学什么推广赚钱
  • 网页制作企业网站作业晋中网络推广
  • 有专门做食品的网站吗网页设计与制作个人网站模板
  • 北京科技网站建设互联网营销师证书
  • 临淄百度信息网影响关键词优化的因素
  • 微信授权登录第三方网站开发怎样做网站卖自己的产品
  • 转业做网站的工具百度联系方式
  • 长春做网站seo的重庆关键词优化服务
  • 龙岩小程序报价seo网站优化服务商
  • 红河州建设局网站百度高级搜索技巧
  • 番禺公司网站建设yande搜索引擎官网入口
  • 广州网站建设 易企建站公司ip或域名查询网
  • 中国建设官方网站登录苏州搜索引擎排名优化商家
  • 全国信息企业公示系统官网网站关键词优化推广哪家快
  • 温州网站公司互联网营销方式有哪些
  • 深圳龙岗淘宝网站建设公司有哪些百度推广平台登录入口
  • 昆山市有没有做网站设计的自己做网站需要多少钱
  • 精品课程网站建设论文网上营销方式和方法
  • 同城分类信息网站免费seo网站诊断免费
  • 17网站一起做网店普宁轻纺城seo 优化教程
  • 湖州网站优化成都seo服务
  • 云南城市建设职业学院成绩查询网站网站及搜索引擎优化建议
  • 不再单独建设网站企业如何开展网络营销
  • 国外做黄漫的网站有哪些临沂google推广
  • 备案网站资料上传教程短视频seo优化
  • 综合型b2b电子商务平台有哪些seo每日一帖
  • 酒店网站建设注意什么社群营销的十大案例
  • 36氪网站是用什么做的北京网站优化平台
  • 齐齐哈尔城市建设档案馆网站网络营销方式有几种