检索
①Elasticsearch是一个分布式搜索服务,提供Restful API,底层基于Lucene,采用多shard(分片)的方式保证数据安全,并且提供自动resharding的功能,github等大型的站点也是采用了ElasticSearch作为其搜索服务
②注意,用JAVA写的,起动默认要2G的内存,可-e ES_JAVA_OPTS="-Xms256m -Xmx256m"指定内存
③端口:9200,9300(集群),访问9200端口返回信息就说明按装成功了,官网有详细的中文说明文档
④面向文档,Json作为文档的序列化格式
⑤ES集群→索引(多)→类型(多)→数据集:文档→属性
主机→mysql库(多)→表(多)→数据集:表内容→列
⑥get检索,delete,head检查是否有资源,更新也用put
⑦官网的轻量检索,全文检索,短语检索,高亮检索:查询表达式
ES
①springBoot默认支技两种与ES交互的技术:jest(默认不生效),SpringData ElasticSearch
②SpringData ElasticSearch
→CIient节点信息
→ElasticSearchTemplate操作es
→编写一个ElasticSearchRepository的子接口来操作ES
③Jest:导入Jar,版本跟ES走
→uris:配罝主机ip
→@Autowired注入JestCIient使用
→构建索引(保存)功能:Index index = new Index.Builder(student).index(“mysql”).type(“tb_student”).build(); jestClient.execute(index);
→检索:new Search.Builder(jsonsearch).addIndex…
④SpringData ElasticSearch:导入starter-data-ES
→cluster-name:节点名称,就是访问9200里的节点信息
→cluster-nodes:ip:9300
→在github查看spring data和ES的版本对应关系
→编写ElasticSearchRepository子接口,并注入
→@Document声明在实体类
→支持自定义查询,只要写方法名不需要实现,也支持@Query在方法上自已写查询语法,详情官网