我想从我的ElasticSearch索引中获取数据。
所以我有以下索引:
使用Node,如果我这样做:
const hits = await elasticClient.search({
index: esIndex,size: 999,sort: 'ts:desc',body: {
query: {
bool: {
must: [
{
term: {
userId: '56',},}
],});
它将返回:
[
{
"_index": "events_rc","_type": "_doc","_id": "tf-szm0B_tB6kax4xmnr","_score": null,"_source": {
"userId": "56","eventName": "synchronizationStart","ts": 1571130486383
}
},{
"_index": "events_rc","_id": "tP-szm0B_tB6kax4xmnr","eventName": "showSynchronizationmodal","ts": 1571130447209
}
}
]
但是如果我执行以下查询:
const hits = await elasticClient.search({
index: esIndex,body: {
query: {
bool: {
must: [
{
term: {
eventName: 'synchronizationStart',});
它将返回一个空数组...
我想知道为什么它可以找到与userId
而不是eventName
的匹配项?
两个字段的映射似乎相同
"eventName": {
"type": "text","fields": {
"keyword": {
"type": "keyword","ignore_above": 256
}
}
"userId": {
"type": "text","ignore_above": 256
}
}
thx