我需要在 Vespa 中创建一个搜索定义文件,其中可以在 JSON 对象内包含一个 JSON 数组,并且所有字段均可搜索
例如-
{
"department": "education",
"designation": "student",
"person": {
"name": "steve",
"city": "delhi",
"hobbies": [
{
"hobbyName": "cricket",
"type": "outdoor"
},
{
"hobbyName": "chess",
"type": "indoor"
}
]
}
}
这里我需要搜索 person.name、person.city、person.hobbies.hobbyName、person.hobbies.type。
最佳答案
使用array of struct ,这样的事情应该可以帮助您开始:
search person {
document person {
field name type string {
indexing: summary | index
}
field city type string {
indexing: summary | index
}
struct hobby {
field hobbyName type string {}
field type type string {}
}
field hobbies type array<hobby> {
indexing: summary
struct-field hobbyName { indexing: attribute }
struct-field type { indexing: attribute }
}
}
}
关于vespa - 是否可以在搜索定义中的 JSON 对象内创建 JSON 数组,并且所有字段都可以在 vespa.ai 中搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59854298/