这里先给出索引里的所有数据:
"hits" : { "total" : { "value" : 5, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "drink", "_type" : "_doc", "_id" : "1", "_score" : 1.0, "_source" : { "name" : "kele", "price" : 5, "describe" : [ "feizai", "kuaile", "shui" ] } }, { "_index" : "drink", "_type" : "_doc", "_id" : "2", "_score" : 1.0, "_source" : { "name" : "xuebi", "price" : 3, "describe" : [ "feizai", "paopao", "shui" ] } }, { "_index" : "drink", "_type" : "_doc", "_id" : "3", "_score" : 1.0, "_source" : { "name" : "hongniu", "price" : 8, "describe" : [ "dajixue", "kuaile", "shui" ] } }, { "_index" : "drink", "_type" : "_doc", "_id" : "4", "_score" : 1.0, "_source" : { "name" : "kuangquanshui", "price" : 1, "describe" : [ "yiban", "putong", "shui" ] } }, { "_index" : "drink", "_type" : "_doc", "_id" : "5", "_score" : 1.0, "_source" : { "name" : "nongfu kuangquanshui", "price" : 3, "decribe" : [ "haode", "kuangquan", "shui" ] } } ]一.query string search:该语法可以类似于在url请求地址后面拼接参数的请求方式 (1)GET /index/_search || GET /index/type/_search:搜索索引下所有文档 (2)GET /index/_search?q=参数名:参数值&sort=参数名:排序方式:对索引下所有文档带待条件的筛选和排序,参数可以自由组合拼接,用&连接即可 二.query DSL:结构化查询 (1).查所有文档 (2).对索引下所有文档带待条件的筛选和排序,结果和query string search方式的一样 (3).分页查询 (4).只查特定字段 三.query filter:通过这个语法可以对查询的数据进行过滤,得到想要的结果 四.全文检索,检索时,搜索的字段会被拆解开来,去匹配倒排索引,只要有一个匹配上就可以作为结果返回,匹配度最高的排前面 五.短语搜索,这个搜索的要求是输入的字段搜索条件要和es里的字段包含一摸一样的文本,才能算匹配,才能作为结果返回 六.高亮搜索,在返回结果里会加上html的标签,可以高亮显示