我正在使用文档引用将父字段导入子文档。虽然对父字段的搜索有效,但父字段本身似乎不包含在搜索结果中,只有子字段。
要使用文档中的示例,在 using或直接检索via时salesperson_name
不会出现在fields
条目中。id:test:ad::1
query=John
id:test:ad::1
GET
这是我的文档模型的简化配置:
搜索定义
person.sd - 父级
search person {
document person {
field name type string {
indexing: summary | attribute
}
}
fieldset default {
fields: name
}
}
event.sd - 孩子
search event {
document event {
field code type string {
indexing: summary | attribute
}
field speaker type reference<person> {
indexing: summary | attribute
}
}
import field speaker.name as name {}
fieldset default {
fields: code
}
}
文件
p1 - 人
{
"fields": {
"name": "p1"
}
}
e1 - 事件
{
"fields": {
"code": "e1",
"speaker": "id:n1:person::1"
}
}
查询结果
curl -s "http://localhost:8080/search/?yql=select%20*%20from%20sources%20*where%20name%20contains%20%22p1%22%3B" | python -m json.tool
如您所料,这将返回 e1 和 p1,因为name
两者都存在。但的fields
不e1
包括name
。
{
"root": {
"children": [
{
"fields": {
"documentid": "id:n1:person::1",
"name": "p1",
"sddocname": "person"
},
"id": "id:n1:person::1",
"relevance": 0.0017429193899782135,
"source": "music"
},
{
"fields": {
"code": "e1",
"documentid": "id:n1:event::1",
"sddocname": "event",
"speaker": "id:n1:person::1"
},
"id": "id:n1:event::1",
"relevance": 0.0017429193899782135,
"source": "music"
}
],
...
"fields": {
"totalCount": 2
},
}
}