热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

eselasticsearchsearchDSLintervals3

世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。问:intervals有什么特点?答&

世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。

问:intervals有什么特点?
答:
在这里插入图片描述
问:intervals如何使用?
答:

# intervals
# 映射
PUT /intervals_1_test
{"mappings": {"properties": {"name": {"type": "text"},"num" : {"type": "integer"}}}
}# 索引
POST /intervals_1_test/_doc/1
{"name": "hello","num" : 1
}# 索引
POST /intervals_1_test/_doc/2
{"name": "hello good","num" : 100
}# 索引
POST /intervals_1_test/_doc/3
{"name": "good hello","num" : 5
}# 索引
POST /intervals_1_test/_doc/4
{"name": "hello hello","num" : 10
}# 搜索 - 普通匹配
GET /intervals_1_test/_search
{"query": {"match": {"name": "hello"}}
}# 结果
{"took" : 10,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 4,"relation" : "eq"},"max_score" : 0.09935807,"hits" : [{"_index" : "intervals_1_test","_type" : "_doc","_id" : "4","_score" : 0.09935807,"_source" : {"name" : "hello hello","num" : 10}},{"_index" : "intervals_1_test","_type" : "_doc","_id" : "1","_score" : 0.0910362,"_source" : {"name" : "hello","num" : 1}},{"_index" : "intervals_1_test","_type" : "_doc","_id" : "2","_score" : 0.07145072,"_source" : {"name" : "hello good","num" : 100}},{"_index" : "intervals_1_test","_type" : "_doc","_id" : "3","_score" : 0.07145072,"_source" : {"name" : "good hello","num" : 5}}]}
}# 搜索 - match
GET /intervals_1_test/_search
{"query": {"intervals": {"name": {"all_of": {"ordered" : true,"intervals": [{"match": {"query" : "hello","max_gaps": 0,"ordered" : true,"analyzer": "standard","filter" : {"not_containing": {"match": {"query": "key"}}}}},{"any_of": {"intervals": [{"match": {"query": "good"}}]}}]}}}}
}# 结果
{"took" : 0,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 1,"relation" : "eq"},"max_score" : 0.5,"hits" : [{"_index" : "intervals_1_test","_type" : "_doc","_id" : "2","_score" : 0.5,"_source" : {"name" : "hello good","num" : 100}}]}
}# 搜索 - prefix wildcard
GET /intervals_1_test/_search
{"query": {"intervals": {"name": {"all_of": {"ordered" : true,"intervals": [{"prefix": { "prefix": "he" }},{"wildcard": { "pattern": "hell*" }}]}}}}
}# 结果
{"took" : 0,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 1,"relation" : "eq"},"max_score" : 0.5,"hits" : [{"_index" : "intervals_1_test","_type" : "_doc","_id" : "4","_score" : 0.5,"_source" : {"name" : "hello hello","num" : 10}}]}
}# 搜索 - fuzzy
GET /intervals_1_test/_search
{"query": {"intervals": {"name": {"all_of": {"intervals": [{"fuzzy": {"term": "good"}}],"filter": {"after": {"prefix": {"prefix": "hello"}}}}}}}
}# 结果
{"took" : 1,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 1,"relation" : "eq"},"max_score" : 0.5,"hits" : [{"_index" : "intervals_1_test","_type" : "_doc","_id" : "2","_score" : 0.5,"_source" : {"name" : "hello good","num" : 100}}]}
}


推荐阅读
author-avatar
有你世界就很美_484
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有