elasticsearch 具有多级子级数据的Elasticsearch查询
鉴于此示例数据:elasticsearch 具有多级子级数据的Elasticsearch查询,elasticsearch,nosql,elasticsearch,Nosql,鉴于此示例数据: "users": { "user1": { "first": "john", "last": "bellamy" }, "user2": { ..... ..... } } 我如何设置elasticsearch来查询/搜索子第一个和最后一个?Ohter教程仅显示一个级别的子级,而不是这两个或更多级别的子级 我试着寻找一个解决方案,我猜它与映射选项有关 我几天前刚开始e
"users": {
"user1": {
"first": "john",
"last": "bellamy"
},
"user2": {
.....
.....
}
}
我如何设置elasticsearch来查询/搜索子第一个和最后一个?Ohter教程仅显示一个级别的子级,而不是这两个或更多级别的子级
我试着寻找一个解决方案,我猜它与映射
选项有关
我几天前刚开始elasticsearch,已经成功地设置和添加了数据。这对我很有用
{
"query": {
"bool": {
"must": [{
"term": {
"users.user2.firstname": {
"value": "sumit"
}
}
}]
}
}
}
嵌套用户方法
映射
{
"mappings": {
"test_type": {
"properties": {
"users": {
"type": "nested",
"properties": {
"firstname": {
"type": "text"
},
"lastname": {
"type": "text"
}
}
}
}
}
}
}
质疑
这对我有用
{
"query": {
"bool": {
"must": [{
"term": {
"users.user2.firstname": {
"value": "sumit"
}
}
}]
}
}
}
嵌套用户方法
映射
{
"mappings": {
"test_type": {
"properties": {
"users": {
"type": "nested",
"properties": {
"firstname": {
"type": "text"
},
"lastname": {
"type": "text"
}
}
}
}
}
}
}
质疑
用户不是嵌套的类型或密钥散列?@user3775217我不这么认为,因为users
不是数组。users不是嵌套的类型或密钥散列?@user3775217我不这么认为,因为users
不是数组。user1
,user2
(又称userId)是我想返回的问题,我想这样使用它:找到名为john的用户
->然后重新访问userId因为user1和user2是用户,您可以将用户作为嵌套对象,然后使用嵌套的内部hit这里的问题是user1
,user2
(又称userId)是我想要返回的问题,我想这样使用它:找到名为john的用户
->然后重新访问userid因为user1和user2是用户,您可以将用户设置为嵌套对象,然后使用嵌套的innerhits