如何在搜索结果中包含导入的字段?

Ric*_*ger 3 vespa

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

要使用文档中的例子,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
  }
}
Run Code Online (Sandbox Code Playgroud)

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
  }
}
Run Code Online (Sandbox Code Playgroud)

文件

p1 - 人

{
  "fields": {
    "name": "p1"
  }
}
Run Code Online (Sandbox Code Playgroud)

e1 - 事件

{
  "fields": {
    "code": "e1",
    "speaker": "id:n1:person::1"
  }
}
Run Code Online (Sandbox Code Playgroud)

查询结果

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
    },
  }
}
Run Code Online (Sandbox Code Playgroud)

Jo *_*gum 6

目前,您需要将导入的"名称"添加到默认摘要中

 import field speaker.name as name {}

 document-summary default {
    summary name type string{}
  }
Run Code Online (Sandbox Code Playgroud)

有关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"
        }
    ],
Run Code Online (Sandbox Code Playgroud)

我们将改进这方面的文档.感谢非常详细的报道.