最佳查询Elasticsearch中更新后的返回结果?
最近,我在一个商店网站上工作,用户可以从移动应用程序订购,并且管理员可以在管理仪表板中搜索用户数据,我将弹性搜索用作Rails应用程序中的搜索引擎。商店管理员可以创建自定义查询并检索他们的自定义结果,每个通过移动应用程序订购的用户我创建两个自定义索引并将其插入弹性。这些索引是用户配置文件数据和用户事件。在个人资料中收集的用户配置文件,例如名字,姓氏...而在此事件中,我收集了登录名的用户操作...移动应用程序中的用户可以更新他/她的个人资料,因此每次我都必须创建一个配置文件索引并将其插入我的弹性中。我有问题,假设一个信息的用户创建的配置文件:
profile-2022-05-29
{
"event": "sign_up",
"profile_id": 1,
"profile": {
"id": 1,
"first_name": "helen"
}
}
第二天使用这样的新数据更新她的个人资料:
profile_2022-05-30
{
"event": "sign_up",
"profile_id": 1,
"profile": {
"id": 1,
"first_name": "rose",
"last_name": "brown"
}
}
因此,如果我想找到一个用户,我的弹性中有两个不同的配置文件索引名称为“棕色”,并具有事件“ sign_up”弹性仅返回最后一个索引“ profile-2022-05-30 ”文档,即带有更新信息的用户配置文件,但我希望弹性返回这两个索引文档是因为用户更新了她的配置文件,因此我为一个用户提供了两个索引。 有人可以帮助我什么是返回这两个索引的弹性中最好的查询DSL。
这是我的弹性查询:
GET profile_*/_search
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"last_name": "brown"
}
},
{
"match_phrase": {
"event": "app_open"
}
}
]
}
}
}
更新:每次我想查询我的数据时,我都会搜索这样的所有索引:
Get profile_*
{
"some query"
}
Recently I work on a store website where users could order from mobile applications and the admin could search over user data in the admin dashboard, I use elastic search as a search engine in my rails apps. Store admin could create custom queries and retrieve their custom results, for each user who orders by the mobile app I create two custom indexes and insert them on elastic. these indexes are user profile data and user events. In profile User profile collected like first name, last name... and in the event, I collect user actions like login sign up...Users in the mobile app could update him/her profile so each time I have to create a profile index and insert it in my elastics. I have a problem, assume a user-created profile with this informations:
profile-2022-05-29
{
"event": "sign_up",
"profile_id": 1,
"profile": {
"id": 1,
"first_name": "helen"
}
}
and next day update her profile with new data like this:
profile_2022-05-30
{
"event": "sign_up",
"profile_id": 1,
"profile": {
"id": 1,
"first_name": "rose",
"last_name": "brown"
}
}
So I have two different profile indexes in my elastic for one user now if I want to find a user the last name is "brown" and have the event "sign_up" Elastic only returns the last index "profile-2022-05-30" document, that is the user profile with updated information but I expect that elastic return both indexes document because the user updates her profile so I have two indexes for one user.
Does anyone could help me what is the best query DSL in elastic that returns both indexes.
this is my elastic query:
GET profile_*/_search
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"last_name": "brown"
}
},
{
"match_phrase": {
"event": "app_open"
}
}
]
}
}
}
Updated: Each time I want to query over my data I search over all of my indexes like this:
Get profile_*
{
"some query"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论