我正在使用 Firebase Flashlight 查询我的 Firebase 数据库,但无法对结果进行排序。
我正在使用此查询:
this.elasticConfig = {
type: 'guest',
body: {
from: 0,
size: 20,
query: {
bool: {
must: [
{
match: {
isApproved: false
}
},
{
match: {
isCheckedIn: false
}
},
{
match: {
eventId: event.id
}
}
]
}
},
sort: [
{
name: {
order: 'asc'
}
}
]
}
};
但我从 elasticsearch 收到此错误:
Fielddata is disabled on text fields by default. Set fielddata=true on [name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.
我觉得很奇怪,一个简单的字母排序操作需要您使用“大量内存”。
我在查询中是否遗漏了某些内容?或者我还可以做些什么来让它发挥作用?
最佳答案
如果这是 ES 5 并且该字段已由 Elasticsearch 自动映射,请尝试对 name.keyword
进行排序。否则,您需要将 name
字段设置为 keyword
类型,或者向其中添加 keyword
子字段以搜索 name.keyword
,当然,子字段的类型为keyword
。
关于firebase - ElasticSearch 排序给出 fielddata 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44112841/