3

我正在使用文档引用将父字段导入子文档。虽然对父字段的搜索有效,但父字段本身似乎不包含在搜索结果中,只有子字段。

要使用文档中的示例,在 using或直接检索via时salesperson_name不会出现fields条目中。id:test:ad::1query=Johnid:test:ad::1GET

这是我的文档模型的简化配置:

搜索定义

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两者都存在。fieldse1包括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
    },
  }
}
4

2 回答 2

6

目前,您需要通过以下方式将导入的“名称”添加到默认摘要中

 import field speaker.name as name {}

 document-summary default {
    summary name type string{}
  }

更多关于http://docs.vespa.ai/documentation/document-summaries.html中的明确文档摘要

然后您的查询结果将返回

 "children": [
        {
            "fields": {
                "documentid": "id:n1:person::1",
                "name": "p1",
                "sddocname": "person"
            },
            "id": "id:n1:person::1",
            "relevance": 0.0017429193899782135,
            "source": "stuff"
        },
        {
            "fields": {
                "code": "e1",
                "documentid": "id:n1:event::1",
                "name": "p1",
                "sddocname": "event",
                "speaker": "id:n1:person::1"
            },
            "id": "id:n1:event::1",
            "relevance": 0.0017429193899782135,
            "source": "stuff"
        }
    ],

我们将改进这方面的文档。感谢您非常详细的撰写。

于 2017-11-28T10:37:39.053 回答
2

将“summary”添加到父文档类型中导入字段的索引语句中。

例如,在文档示例中,将“salesperson”文档类型中的“name”字段更改为“indexing: attribute | summary”。

于 2017-11-27T16:22:49.113 回答