Elasticsearch随机检索&&嵌套文档检索

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/GodsLeft/article/details/88984402

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": {}
                    }
                }
            ]
        }
    }
}

参考文章

展开阅读全文

没有更多推荐了,返回首页