【发布时间】:2020-11-06 03:51:18
【问题描述】:
数据集如下
PUT /dataall/test/1
{
"name": "Computer Science 101",
"room": "C12",
"professor": {
"name": "Gregg Payne",
"department": "engineering",
"facutly_type": "full-time",
"email": "payneg@onuni.com"
},
"students_enrolled": 33,
"course_publish_date": "2013-08-27",
"course_description": "CS 101 is a first year computer science introduction teaching fundamental data structures and alogirthms using python. "
}
PUT /dataall/test/2
{
"name": "Theatre 410",
"room": "T18",
"professor": {
"name": "Greg",
"department": "art",
"facutly_type": "part-time",
"email": ""
},
"students_enrolled": 47,
"course_publish_date": "2013-01-27",
"course_description": "Tht 410 is an advanced elective course disecting the various plays written by shakespere during the 16th century"
}
DSL查询如下
GET dataall/_search
{
"query": {
"match": {
"professor.name":"Greg"
}
}
}
映射如下。教授在嵌套的json中
{
"dataall" : {
"mappings" : {
"properties" : {
"course_description" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"course_publish_date" : {
"type" : "date"
},
"dataproduct" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"professor" : {
"properties" : {
"department" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"email" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"facutly_type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"room" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"students_enrolled" : {
"type" : "long"
}
}
}
}
}
预计是 2(因为“Greg”与 Gregg Payne 相似)但我得到的只是第二个文档,它是完全匹配的?
为什么我的查询不起作用?甚至必须匹配_phrase_prefix。
我的其他索引工作正常,是不是因为映射嵌套的json?
【问题讨论】:
-
映射是什么?
-
@Gibbs 添加了映射
标签: elasticsearch dsl elasticsearch-dsl