大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本篇内容主要讲解“ES的基本介绍和使用方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“ES的基本介绍和使用方法”吧!
专注于为中小企业提供成都网站制作、成都网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业连平免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了超过千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
批量插入数据的文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-bulk.html
增,删,改,查 全部遵循refult 风格
使用postman来新建一个文档
1 增加
http://localhost:9200/blog1/article/1
{ "id":1, "title":"在弹性搜索中创建索引时," ,"content":"为什么呢?因为mappings里有写参数在elasticsearch6版本里不支持了,index_analyzer就不支持了,改成了analyzer,改过来,就好了,可以建立索引成功" }
2 查询
根据id来查询 GET : http://localhost:9200/blog1/article/1
根据关键字查询 POST:http://localhost:9200/blog1/article/_search
{ "query":{ "term":{ "content":"因" } } }
使用字符串查询(对查询条件进行分词之后再进行查询) POST : http://localhost:9200/blog1/article/_search
{ "query":{ "query_string":{ "default_field":"content", "query":"创建索引" } } }
# 自带的分词器 POST _analyze { "analyzer": "standard", "text": "The 2 QUICK Brown-Foxex jumped over the lazy dog's bone." } POST _analyze { "analyzer": "simple", "text": "The 2 QUICK Brown-Foxex jumped over the lazy dog's bone." } POST _analyze { "analyzer": "whitespace", "text": "The 2 QUICK Brown-Foxex jumped over the lazy dog's bone." } POST _analyze { "analyzer": "stop", "text": "The 2 QUICK Brown-Foxex jumped over the lazy dog's bone." } POST _analyze { "analyzer": "keyword", "text": "The 2 QUICK Brown-Foxex jumped over the lazy dog's bone." } POST _analyze { "analyzer": "pattern", "text": "The 2 QUICK Brown-Foxex jumped over the lazy dog's bone." }
#创建mapping的简介步骤 #1 向es中插入一条数据 (es7中要使用_doc) PUT my_index_test/_doc/1 { "referrer":"-", "response_code":"200", "remote_ip":"192.168.1.1", "method":"post", "user_name":"zhangsan", "http_version":"1.1", "body_sent":{ "bytes":"0" }, "url":"/query/list" } #2 获取刚刚创建的index mapping GET my_index_test/_mapping #3 删除该index DELETE my_index_test #4 改造刚刚获取的index mapping PUT my_index_test { "mappings": { "properties": { "body_sent": { "properties": { "bytes": { "type": "text" } } }, "http_version": { "type": "keyword" }, "method": { "type": "keyword" }, "referrer": { "type": "keyword" }, "remote_ip": { "type": "ip" }, "response_code": { "type": "keyword" }, "url": { "type": "text" }, "user_name": { "type": "text" } } } } #5 校验刚才插入的数据 GET my_index_test/_doc/1
到此,相信大家对“ES的基本介绍和使用方法”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!