我遇到了簡單的存在篩選器問題。我試圖實現的是,返回所有具有特定字段的文檔。 以下是他繪製了我的索引 -elasticsearch存在對象類型字段的篩選器
"book": {
"dynamic": "true",
"properties": {
"currencies": {
"dynamic": "true",
"properties": {
"bookChallenge000": {
"type": "long"
},
"achievements": {
"type": "long"
},
"bookChallenge001": {
"type": "long"
},
"giftsSent": {
"type": "long"
},
"stars": {
"type": "long"
},
"knightsDonated": {
"type": "long"
}
}
},
"level": {
"type": "long"
},
"description": {
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer",
"type": "string"
},
"additionalMaxMembers": {
"type": "long"
},
"name": {
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer",
"type": "string"
},
"lastUpdated": {
"type": "long"
},
"active": {
"type": "boolean"
},
"bookClubId": {
"type": "string"
},
"attributes": {
"dynamic": "true",
"properties": {
"level": {
"type": "long"
},
"description": {
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer",
"type": "string"
},
"additionalMaxMembers": {
"type": "long"
},
"name": {
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer",
"type": "string"
},
"lastUpdated": {
"type": "long"
},
"active": {
"type": "boolean"
},
"memberCount": {
"type": "long"
},
"inviteStatus": {
"type": "string"
}
}
},
"meta": {
"dynamic": "false",
"properties": {
"bookRewards": {
"dynamic": "false",
"type": "object"
},
"challenges": {
"dynamic": "false",
"type": "object"
},
"grantedRewardInfo": {
"dynamic": "false",
"type": "object"
},
"levelRequirement": {
"type": "long"
},
"membersData": {
"dynamic": "false",
"type": "object"
},
"language": {
"type": "string"
},
"conversations": {
"dynamic": "false",
"type": "object"
},
"bookGoals": {
"dynamic": "false",
"type": "object"
},
"banner": {
"type": "string"
}
}
},
"memberCount": {
"type": "long"
},
"inviteStatus": {
"type": "string"
},
"version": {
"type": "long"
}
}
}
這裏就是我正在尋找的文件 -
{
attributes: {
active: true,
additionalMaxMembers: 0,
description: "famous five",
inviteStatus: "OPEN",
lastUpdated: 1452119518547,
level: 1,
memberCount: 39,
name: "zero"
},
currencies: {
bookChallenge000: 74316,
bookChallenge001: 142580,
bookChallenge002: 165526,
achievements: 582,
giftsSent: 0,
knightsDonated: 161,
stars: 1104
},
meta: {
banner: "enidBlyton_17",
challenges: {
Event014_Challenge_A: {
Currency: "bookChallenge000",
finishtime: 20550267,
goalscore: 30240,
memberscores: {
37339561405: 10,
37349022668: 2000,
37432453846: 20,
37437075798: 0
},
playerCurrency: "UserChallenge000"
},
Event014_Challenge_B: {
Currency: "bookChallenge001",
finishtime: 20290830,
goalscore: 38003,
memberscores: {
37339561405: 20,
37349022668: 38,
37432453846: 590
},
playerCurrency: "UserChallenge000"
}
},
language: "en_US",
levelRequirement: 14,
membersData: {
37442021220: {
achievements: 9,
giftsSent: 0,
knightsDonated: 0,
playerLikes: 28,
stars: 20
},
37493332413: {
achievements: 4,
giftsSent: 0,
knightsDonated: 0,
playerLikes: 0,
stars: 20
}
}
},
active: true,
bookClubId: "6106890",
inviteStatus: "OPEN",
memberCount: 39,
additionalMaxMembers: 0,
lastUpdated: 1452119518547,
description: "famous five",
name: "zero",
level: 1
}
我的查詢是非常簡單的,我需要這在他們的挑戰領域的所有文件。
curl -X'GET' localhost:9200/book_index/_search -d '{"filter": {"exists" : { "field" : "challenges" }}}'
但它不返回任何文件,我有挑戰信息的100個文件。 我試過meta.challenges,也是challenges.membersData,但它不起作用。 雖然如果我直接尋找橫幅或語言字段,我會得到預期的結果,但不是對象類型字段。
如何獲取所有帶有challenge或membersData的文檔?
請告訴我缺少什麼。
能否請您提供至少一個完整的文件?而且正確的映射,因爲你現在看起來已經壞了。 –
當然,它是巨大的,所以削減了它的一部分,現在更新了完整的映射和完整的文檔。 – dev123