如何通过弹性搜索来搜索嵌套对象 [英] How to search nested objects with elastic-search

查看:55
本文介绍了如何通过弹性搜索来搜索嵌套对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,到目前为止,我还无法弄清楚这一点.希望有人可以提供一些见识.

OK, I've not been able to figure this out thus far. Hoping someone can offer some insight.

鉴于以下文档,我如何搜索视频标题中包含测试"的视频的所有文档?我正在使用HTTP API. (基本上,您如何通过弹性搜索来搜索嵌套对象?我知道那里必须有文档,但我实际上还没有找到任何文档.)

Given the documents below, how would I search for all documents with a video that has "test" in the video title? I'm using the HTTP API. (Basically, how do you search nested objects with elastic search? I know there has to be docs out there, but I haven't really been able to find any.)

[{
    id:4635,
    description:"This is a test description",
    author:"John",
    author_id:51421,
    video: {
        title:"This is a test title for a video",
        description:"This is my video description",
        url:"/url_of_video"
    }
},
{
    id:4636,
    description:"This is a test description 2",
    author:"John",
    author_id:51421,
    video: {
        title:"This is an example title for a video",
        description:"This is my video description2",
        url:"/url_of_video2"
    }
},
{
    id:4637,
    description:"This is a test description3",
    author:"John",
    author_id:51421,
    video: {
        title:"This is a test title for a video3",
        description:"This is my video description3",
        url:"/url_of_video3"
    }
}]

推荐答案

好,我终于找到了这些页面(事先应该花更多的时间在文档上),看来我们将保存视频的属性设置为:嵌套,然后使用嵌套查询.

OK, I finally found these pages (should have taken more time with the docs beforehand) and it seems we set the property that holds the video to type:nested, then use nested queries.

http://www. elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html

http://www. elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-filter.html

希望这对将来的人有帮助.

Hope this helps someone down the road.

这篇关于如何通过弹性搜索来搜索嵌套对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆