ElasticSearch
1、概述
1.1 ElasticSearch是一个 基于Lucene 的 搜索服务器;
1.2 ElasticSearch 提供了一个分布式多用户能力的全文搜索引擎,基于 RESTful web接口;
1.3 Elasticsearch是用Java语言编写,是当前流行的 企业级 搜索引擎;
2、基础使用(CURD)
1.1、创建 内容/索引
http://localhost:9200/<index>/<type>/[<id>]
<index>:索引名称(必填)、 <type>:类型(必填) <id>:索引ID
eg:
http://localhost:9200/<index>/<type> 不指定ID,需要使用post请求;
http://localhost:9200/<index>/<type>/<id> 指定ID,可自动生成ID,用put请求;
1.2、更新 内容/索引
http://localhost:9200/<index>/<type>/<id>
根据ID修改内容,put请求;
1.3、获取 内容/索引
http://localhost:9200/<index>/<type>/<id>
根据ID获取内容、索引,get请求;
1.4、删除 内容/索引
http://localhost:9200/<index>/<type>/<id>
根据ID删除内容、索引,delete请求;
1.5、全部/条件 查询内容/索引
http://localhost:9200/[<index>]/[<type>]/_search [<index>]:可选 [<type>]:可选 _search:搜索所有索引和所有类型
post请求;
3、请求正文
3.1、一个json对象,包含一个 'query' 的属性 、可以使用DSL(ElasticSearch自己基于JSON的域特定语言,可以在其中表达查询和过滤器);
3.2、查询字符串查询
{
	"query":{
		"query_string":{
			"query":"The"
		}
	}
}
3.3、指定搜索的字段
{
	"query":{
		"query_string":{
			"query":"The",
			"fields":["title"]
		}
	}
}
 
                    
                     
                    
                 
                    
                 
                
            
         
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号