ElasticSearch
随机检索文档
{
"from": 0,
"size": 200,
"_source": [
"title",
"location"
],
"sort": {
"_script": {
"script": "Math.random()",
"type": "number"
}
}
}
嵌套文档检索并给出的定嵌套文档的位置
GET zhuvideo/video/_search
{
"_source": ["location", "title"],
"query": {
"bool": {
"must": [
{"match_phrase": {"title": "friends"}},
{
"nested": {
"path": "content",
"query": {
"match_phrase": {
"content.line_en_lem": "friend"
}
},
"inner_hits": {}
}
}
]
}
}
}
本文介绍了ElasticSearch中两种高级检索技术:随机检索文档及嵌套文档检索,并提供了具体的API示例。随机检索通过使用脚本排序实现,而嵌套文档检索则利用了nested查询并返回了内联命中信息。
454

被折叠的 条评论
为什么被折叠?



