es

ElasticSearch

ElasticSearch是一个基于Lucene的搜索服务器
做搜索
当查询不规则,数据量比较大的时候,速度要求比较高

lucene原理
把数据保存到索引库中,以供查询使用
原始文档—>文档对象—>域:分析属性和属性值有什么需要关注的—>分词—>索引—>存储

查询索引库

Solr ,ElasticSearch:对 lucene 进行包装,完成解决搜索问题的服务
对比:
Solr利用Zookeeper进行分布式管理 ,而 自己携带分布式协调管理功能
Solr支持多种数据格式,ElasticSearch仅支持json格式
Solr官方提供功能更多,而 ElasticSearch 更注重核心功能,高级功能多有第三方插件
Solr传统搜索表现好于 ElasticSearch 但集群实时搜索时效率明显更低

IK分词器


ES: 端口
9200—浏览器访问
9300—java访问

官网链接: https://www.elastic.co/products/elasticsearch

索引:索引库-indexDB -mysql中的数据库
类型 -type - 表名
映射 -mapping -表结构
有什么域 域值是什么类型 要不要分词 索引存储
文档 -Document -一行数据
域 -Field -字段

grunt server

–创建zhangsan

PUT http://localhost:9200/zhangsan
{
“mappings”:{
“hello”:{
“properties”:{
“id”:{
“type”:“long”,
“store”:true
},
“title”:{
“type”:“text”,
“store”:true,
“index”:true,
“analyzer”:“standard”
},
“content”:{
“type”:“text”,
“store”:true,
“index”:true,
“analyzer”:“standard”
}
}
}
}
}

----删除
DELETE http://localhost:9200/zhangsan2

—创建类型和映射(已经存在索引库)
POST http://localhost:9200/zhangsan2/hello/_mappings
{

"hello":{
    "properties":{
        "id":{
            "type":"long",
            "store":true
        },
        "title":{
            "type":"text",
            "store":true,
            "index":true,
            "analyzer":"standard"
        },
        "content":{
            "type":"text",
            "store":true,
            "index":true,
            "analyzer":"standard"
        }
    }

}

}

—添加数据

{
“id”: 4,
“title”: “E原始文档—>文档对象—>域:分析属性和属性值有什么需要关注的—>分词—>索引—>存储”,
“content”: “新添加文档新添加文档内容2”
}

—根据id查询
GET
http://localhost:9200/zhangsan2/hello/2
—查询关键词
http://localhost:9200/zhangsan2/hello/_search
{
“query”:{
“term”:{
“content”:“添”
}
}
}

query_string查询
{
“query”:{
“query_string”:{
“default_field”:“content”,
“query”:“档新添加文档内容”

    }
}

}


中文分词器
GET http://localhost:9200/_analyze?analyzer=standard&text=我是张三

创建时添加
“analyzer”:“ik_max_word”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值