我正在執行一箇舊項目來維護,並且因爲查詢一天而停滯不前。
我使用的elasticsearch版本是1.7,但我不認爲這與我的問題有關。已過濾的查詢和集合上的術語
我有一些教師文件:
{
"id": 244,
"degree": [],
"teacherDiplomaRelation": [],
"user": {
"enabled": true
},
"teacherClassDisciplineRelation": [
SEE BELOW
}
的teacherClassDisciplineRelation是N次此格式(每對夫婦levelTree /紀律,我有)
{
"levelTree": {
"id": 34,
"label": "1st year of college",
"slugLastLevelDisplay": "college"
},
"discipline": {
"id": 1,
"label": "Maths",
"slug": "maths"
},
"cityLocation": "10.1010,10.1010"
}
現在我想一切老師啓用並在他們的學科有數學。我的查詢是:
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"user.enabled": true
}
},
{
"term": {
"teacherClassDisciplineRelation.discipline.slug": "maths"
}
}
]
}
}
}
},
"size": {
"from": 0,
"size": 15
}
}
映射:
"teacherClassDisciplineRelation": {
"type": "nested",
"properties": {
"cityLocation": {
"type": "geo_point",
"store": true
},
"discipline": {
"properties": {
"id": {
"type": "string",
"store": true
},
"label": {
"type": "string",
"boost": 7.0,
"store": true,
"analyzer": "custom_analyzer"
},
"slug": {
"type": "string",
"boost": 7.0,
"index": "not_analyzed",
"store": true,
"norms": {
"enabled": true
}
}
}
}
問題:
我與"user.enabled": true
查詢給我一些成果, 我與"teacherClassDisciplineRelation.discipline.slug": "maths"
查詢總是給我0結果但我已經檢查了指數,我應該有一些結果。
我是elasticsearch的新手,但我找不到爲什麼我的結果總是0. 任何想法爲什麼?
請分享映射。 'GET index_name/type_name/_mapping' – Richa
@Richa我剛剛添加了它 – goto