我正在执行一个旧项目来维护,并且因为查询一天而停滞不前。
我使用的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