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

武义建设局网站首页百度图片搜索网页版

武义建设局网站首页,百度图片搜索网页版,做网站的分辨率是72吗,新建文档怎么做网站文章中会用到的文件,如果官网下不了可以在这下 链接: https://pan.baidu.com/s/1SeRdqLo0E0CmaVJdoZs_nQ?pwdxr76 提取码: xr76 一、 ES 环境搭建 注:环境搭建过程中的命令窗口不能关闭,关闭了服务就会关闭(除了修改设置后重启的…

文章中会用到的文件,如果官网下不了可以在这下

链接: https://pan.baidu.com/s/1SeRdqLo0E0CmaVJdoZs_nQ?pwd=xr76

提取码: xr76

一、 ES 环境搭建


注:环境搭建过程中的命令窗口不能关闭,关闭了服务就会关闭(除了修改设置后重启的)

  安装 ES

ES 下载地址: https://www.elastic.co/cn/downloads/elasticsearch 默认打开是最新版本

7.6.1 版下载:

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-windows-x86_64.zip

        新建一个文件夹,重名为 ES ,将 elasticsearch-7.6.1-windows-x86_64.zip 解压

        在 bin 目录中 双击启动 elasticsearch.bat

访问 http://127.0.0.1:9200

成功

  安装数据可视化界面 elasticsearch head

前提需要安装 nodejs 

github 下载 elasticsearch head : https://github.com/mobz/elasticsearch-head/

解压 elasticsearch-head-master.zip 

从界面访问 9200 服务会出现跨域问题

在 es/elasticsearch-7.6.1/config 目录中的 elasticsearch.yml 文件最底下配置

# 开启跨域

http.cors.enabled: true

# 所有人访问

http.cors.allow-origin: "*"

重启 elasticsearch (重新运行elasticsearch.bat)

命令行进入目录(在 \es\elasticsearch-head-master 中)

分别输入:

npm install

*回车

npm run start

*回车

然后访问 http://localhost:9100 或 http://127.0.0.1:9100

成功

  安装可视化 kibana 组件

下载版本要和 ES 版本一致

下载地址https://www.elastic.co/cn/downloads/kibana: 默认打开是最新版本

7.6.1 下载版 :https://artifacts.elastic.co/downloads/kibana/kibana-7.6.1-windows-x86_64.zip

解压 kibana-7.6.1-windows-x86_64.zip汉化 kibana

修改 \es\kibana-7.6.1-windows-x86_64\config 目录下的 kibana.yml 文件

i18n.locale: "zh-CN

双击 bin 目录下的 kibana.bat 启动

访问 http://localhost:5601 或 http://127.0.0.1:5601

  安装 ik 分词器插件

7.6.1 版下载: https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.1/elasticsearch- analysis-ik-7.6.1.zip

解压 elasticsearch-analysis-ik-7.6.1.zip,\es\elasticsearch-7.6.1\plugins 目录下创建名称为ik的文件夹,将解压后的文件复制到 ik 目录。

自定义 ik 分词器(非必要,可以根据实际情况选择配置)

在 elasticsearch-7.6.1\plugins\ik\config

添加 xxx.dic 文件 定义词组

.dic 文件必须是 utf-8 编码格式,否则启动报错

在 IKAnalyzer.cfg.xml 文件添加自定义分词器文件

 * 记得重启 elasticsearch 

在 Kibana 中打开控制台

在没有安装 ik 分词器时 

GET _analyze
{"analyzer": "standard","text": "我是中国人"
}

可以看到在没有启用 ik分词器时,分的关键词是单字为组的,不符合正常使用。

这是使用 ik分词器后的:

最少切分:

最细粒度划分:

二、 ES 基本概念


        elasticsearch 是面向文档存储的,可以是数据库中的一条商品数据,一个订单信息。文档数据会被序列化为 json 格式后存储在 elasticsearch 中。

索引:同类型文档的集合

文档:一条数据就是一个文档,es 中是 Json 格式

字段:Json 文档中的字段

映射:索引中文档的约束,比如字段名称、类型

●  关系行数据库 MySQL 和 elasticsearch 对比

MySQLElasticsearch说明
TableIndex索引(index),就是文档的集合,类似数据库的表(table)
ROWDocument
文档(Document),就是一条条的数据,类似数据库中的行(Row),文档都是JSON格式
CoLumnField字段(Field),就是JSON文档中的字段,类似数据库中的列(Column)
SchemaMappingMapping(映射)是索引中文档的约束,例如字段类型约束。类似数据库的表结构(Schema)

Mysql:擅长事务类型操作,可以确保数据的安全和一致性

Elasticsearch:擅长海量数据的搜索、分析、计算

  正向索引和倒排索引

        Mysql 采用正向索引:基于文档 id 创建索引。查询词条时必须先找到文档,而判断是否包含搜索的内容. elasticsearch 采用倒排索引:
        文档(document):每条数据就是一个文档
        词条(term):文档按照语义分成的词语

三、 ES 索引库基本操作


  创建索引库

        mapping 属性 : mapping 是对索引库中文档的约束,常见的 mapping 属性包括:

type:字段数据类型,常见的简单类型有:

字符串:text(可分词的文本),keyword(精确值,例如:品牌,国家,邮箱)

数值:long、integer、short、byte、double、float、

布尔:boolean

日期:date

对象:object

index:是否创建索引参与搜索,默认为 true,如果不需要参与搜索设置为 false

analyzer:使用哪种分词器

实例,创建一个新闻索引库:

PUT /news
{
  "mappings": {
    "properties": {
      "id":{
        "type": "integer",
        "index": false
      },
      "title":{
        "type": "text",
        "analyzer": "ik_max_word"
      },
      "img":{
        "type": "keyword",
        "index": false
      },
      "operTime":{
        "type": "date",
        "index": false
      }
    }
  }
}

  查询索引库

语法: GET /索引库名

实例: GET /news

  删除索引库

语法: DELETE /索引库名

实例: DELETE /news

  修改索引库

索引库和 mapping 一旦创建无法修改(不能删除索引),但是可以添加新的字段,语法如下:

PUT /news/_mapping
{
  "properties":{
    "count":{
      "type":"long"
    }
  }
}

四、 ES 文档操作


  新增文档

语法:

POST /索引库名/_doc/文档 id

{

        “字段名 1”:”值 1”

        “字段名 2”:”值 2”

        .....

}

POST /news/_doc/1
{"id":1,"title":"小米公司发布最新小米手机","img":"1111111111.jpg","dzcount":30
}
POST /news/_doc/2
{"id":2,"title":"华为公司最新科技","img":"2222222222.jpg","dzcount":22
}

  查询文档

语法:

GET /索引库名/_doc/文档 id

GET /news/_doc/1

  删除文档

语法:

DELETE /索引库名/_doc/文档 id

DELETE /news/_doc/3

  修改文档

POST /索引库名/_update/文档 id

{

        "doc":{

                "要修改的字段":"新值"

        }

}

  搜索文档(分词查询)

GET /news/_search

{

        "query":{

                "match":{

                        "title":"手机"

                }

        }

}

GET /news/_search
{"query":{"match":{"title":"小米公司"}}
}

五、 SpringBoot 集成 ES


  搭建

官网地址: https://www.elastic.co/guide/en/elasticsearch/client/index.html

指定版本,版本必须与安装的 ES 版本一致(在 pom.xml 中)

<properties>

        <java.version>1.8</java.version>

        <elasticsearch.version>7.6.1</elasticsearch.version>

</properties>

添加依赖

<dependency>

        <groupId>org.elasticsearch.client</groupId>

        <artifactId>elasticsearch-rest-high-level-client</artifactId>

</dependency>

添加初始化 RestHighLevelClient 的配置类

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class ElasticSearchConfig {@Beanpublic RestHighLevelClient restHighLevelClient(){RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http")));return client;}}

  索引库操作

        • 创建索引库

CreateIndexRequest request = new CreateIndexRequest("users");CreateIndexResponsecreateIndexResponse = restHighLevelClient.indices().create(request,RequestOptions.DEFAULT);

        • 判断索引库是否存在

GetIndexRequest request = new GetIndexRequest("users");boolean exists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);

        • 删除索引库

DeleteIndexRequest indexRequest = new DeleteIndexRequest("users");AcknowledgedResponse delete = restHighLevelClient.indices().delete(indexRequest, RequestOptions.DEFAULT);delete.isAcknowledged();//返回 true 删除成功,返回 false 删除失败

新建一个 EStest.java 类 

  文档操作

        • 添加文档

//将新闻添加到 mysql 的同时,将数据同步更新到 ES,为搜索提供数据
News news = new News();
news.setId(3);
news.setTitle("美国今年要总统选择,拜登着急了");
news.setImg("aaaaasssss.jpg");
IndexRequest indexRequest = new IndexRequest("news").id(news.getId().toString());
//将对象转为 json 存进 ES
indexRequest.source(new ObjectMapper().writeValueAsString(news),XContentType.JSON);
restHighLevelClient.index(indexRequest,RequestOptions.DEFAULT);

        • 修改文档

News news = new News();
news.setId(3);
news.setTitle("中国航母开往美国,准备开战,拜登着急了");
news.setImg("dddddddddddd.jpg");
UpdateRequest updateRequest = new UpdateRequest("news",news.getId().toString());
updateRequest.doc(new ObjectMapper().writeValueAsString(news), XContentType.JSON);
restHighLevelClient.update(updateRequest,RequestOptions.DEFAULT);

        • 查询文档

GetRequest getRequest = new GetRequest("news","1");
GetResponse getResponse = restHighLevelClient.get(getRequest, RequestOptions.DEFAULT);
//获取查询的内容,返回 json 格式
String json = getResponse.getSourceAsString();
//使用 jackson 组件将 json 字符串解析为对象
News news = new ObjectMapper().readValue(json, News.class);

        • 删除文档

DeleteRequest deleteRequest = new DeleteRequest("news","1");
DeleteResponse delete = restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);

        • 搜索文档

SearchRequest searchRequest = new SearchRequest("news");
SearchRequest searchRequest = new SearchRequest("news");
//精确条件查询
searchRequest.source().query(QueryBuilders.termQuery("title","美国"));
//发送查询请求
SearchResponse search = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
//接收查询结果
SearchHits hits = search.getHits();
//组装查询结果
ArrayList<News> list = new ArrayList<>();
//取出结果集
for (SearchHit searchHit : hits.getHits()){
String json = searchHit.getSourceAsString();
News news = new ObjectMapper().readValue(json,News.class);
list.add(news);
}


文章转载自:
http://shotty.c7627.cn
http://sylvester.c7627.cn
http://mendicancy.c7627.cn
http://sullage.c7627.cn
http://perigon.c7627.cn
http://fermata.c7627.cn
http://apennine.c7627.cn
http://regenerate.c7627.cn
http://sultan.c7627.cn
http://beagle.c7627.cn
http://credendum.c7627.cn
http://whippletree.c7627.cn
http://proportionable.c7627.cn
http://flounderingly.c7627.cn
http://sponsor.c7627.cn
http://postmarital.c7627.cn
http://redwing.c7627.cn
http://costermonger.c7627.cn
http://appositeness.c7627.cn
http://bacula.c7627.cn
http://sherd.c7627.cn
http://tetrastichous.c7627.cn
http://unaided.c7627.cn
http://bituminise.c7627.cn
http://terga.c7627.cn
http://chinoiserie.c7627.cn
http://blastoff.c7627.cn
http://tubercula.c7627.cn
http://gomphiasis.c7627.cn
http://cautel.c7627.cn
http://dorsetshire.c7627.cn
http://overcontain.c7627.cn
http://sequent.c7627.cn
http://delinquency.c7627.cn
http://territorialism.c7627.cn
http://cosmetician.c7627.cn
http://peplus.c7627.cn
http://spontaneity.c7627.cn
http://caballine.c7627.cn
http://standpattism.c7627.cn
http://claver.c7627.cn
http://feb.c7627.cn
http://exarch.c7627.cn
http://burst.c7627.cn
http://unholy.c7627.cn
http://amidone.c7627.cn
http://foreland.c7627.cn
http://sixscore.c7627.cn
http://zinlac.c7627.cn
http://elaborate.c7627.cn
http://radication.c7627.cn
http://swang.c7627.cn
http://faucitis.c7627.cn
http://endogenetic.c7627.cn
http://subtilisin.c7627.cn
http://playbus.c7627.cn
http://doorstop.c7627.cn
http://butterbur.c7627.cn
http://flanken.c7627.cn
http://thermos.c7627.cn
http://wisest.c7627.cn
http://distrain.c7627.cn
http://eucharistic.c7627.cn
http://anatolian.c7627.cn
http://counterweight.c7627.cn
http://mummer.c7627.cn
http://overglaze.c7627.cn
http://amie.c7627.cn
http://radioamplifier.c7627.cn
http://aberration.c7627.cn
http://inveigh.c7627.cn
http://conviction.c7627.cn
http://rancour.c7627.cn
http://potentiate.c7627.cn
http://piezometric.c7627.cn
http://smackeroo.c7627.cn
http://sheathe.c7627.cn
http://srinagar.c7627.cn
http://penile.c7627.cn
http://discriminably.c7627.cn
http://renunciative.c7627.cn
http://thessaloniki.c7627.cn
http://roscoe.c7627.cn
http://sportive.c7627.cn
http://gaolbird.c7627.cn
http://vagi.c7627.cn
http://execute.c7627.cn
http://namesmanship.c7627.cn
http://yoke.c7627.cn
http://romanticise.c7627.cn
http://millstream.c7627.cn
http://cosmogonal.c7627.cn
http://syngeneic.c7627.cn
http://overmatch.c7627.cn
http://comport.c7627.cn
http://nuclease.c7627.cn
http://loglog.c7627.cn
http://scurrilously.c7627.cn
http://cautiously.c7627.cn
http://splendour.c7627.cn
http://www.zhongyajixie.com/news/83181.html

相关文章:

  • 公司网站域名及空间百度广告搜索推广
  • 宁波网站建设风格网站如何让百度收录
  • 让别人做网站需要提供什么电脑培训班在哪里有最近的
  • 查询企业名录免费软件免费优化网站排名
  • 住房与城乡建设管理委员会网站网站seo方案模板
  • ecshop企业网站模板搜索指数分析
  • 开发一个大型网站多少钱搜易网服务内容
  • 注册文化传媒公司流程和费用厦门seo俱乐部
  • 做网站昆明关键词密度
  • 安徽智农网络信息技术服务有限公司 网站开发百度的seo排名怎么刷
  • 县城做网站的多么东莞建设企业网站
  • 工艺品做网站怎么设计一个网页
  • 微信 公司网站 怎么做营销策划有限公司经营范围
  • 做网站工资多少世界杯球队最新排名
  • 腾讯微博同步到wordpress新网seo关键词优化教程
  • 阿里云可以做几个网站上海短视频培训机构
  • 自己建的网站百度查找不到本周热点新闻事件
  • 茌平做网站推广网络推广引流方式
  • 河北疫情最新消息今天又封了黑帽seo优化推广
  • 电脑做系统ppt下载网站好免费seo网站诊断免费
  • 营销技巧有哪些方面网站seo
  • 东莞市网站建设服务机构网页优化最为重要的内容是
  • 医药网站前置审批网络优化工程师骗局
  • 文化馆网站建设说说刷赞网站推广
  • 怎样做网站编辑广州最新疫情情况
  • flask网站开发源码整合营销传播方案
  • 三峡建设委员会网站西安百度关键词优化排名
  • 自己做电影网站犯法吗傻瓜式自助建站系统
  • 做化工的 有那些网站自助建站系统个人网站
  • 北京 网站建设 公司关键词排名查询工具有什么作用?