简体   繁体   English

在 vespa.ai 中查询张量

[英]Query tensor in vespa.ai

Imitating: https://blog.vespa.ai/billion-scale-knn/模仿: https ://blog.vespa.ai/billion-scale-knn/

Command line: curl -s -d '{"yql":"select * from user where {\"targetHits\":10}nearestNeighbor(approximate, q_binary_code);","ranking.features.query(q_binary_code)":[1,2,3,4,5,6,7,8,9,10],"hits":10}' -H "Content-Type: application/json" -X POST http://localhost:8080/search/ | jq .命令行: curl -s -d '{"yql":"select * from user where {\"targetHits\":10}nearestNeighbor(approximate, q_binary_code);","ranking.features.query(q_binary_code)":[1,2,3,4,5,6,7,8,9,10],"hits":10}' -H "Content-Type: application/json" -X POST http://localhost:8080/search/ | jq . curl -s -d '{"yql":"select * from user where {\"targetHits\":10}nearestNeighbor(approximate, q_binary_code);","ranking.features.query(q_binary_code)":[1,2,3,4,5,6,7,8,9,10],"hits":10}' -H "Content-Type: application/json" -X POST http://localhost:8080/search/ | jq .

Error message:错误信息:

{
  "root": {
    "id": "toplevel",
    "relevance": 1,
    "fields": {
      "totalCount": 0
    },
    "errors": [
      {
        "code": 4,
        "summary": "Invalid query parameter",
        "source": "content",
        "message": "Expected a tensor value of 'query(q_binary_code)' but has [1,2,3,4,5,6,7,8,9,10]"
      }
    ]
  }
}

Question: How pass q_binary_code ?问题:如何通过q_binary_code

With recent Vespa versions, you can define the query tensor in the schema.使用最近的 Vespa 版本,您可以在模式中定义查询张量。 It must be defined必须定义

schema code {
  document code {
    field id type int {..} 
    field binary_code type tensor<int8>(b[16]) {..}
 }
 rank-profile coarse-ranking {
    inputs {
      query(q_binary_code) tensor<int8>(b[16])
    }
    num-threads-per-search:12
    first-phase { expression { closeness(field,binary_code) } } 
 }

You also must define the rank profile in the query request:您还必须在查询请求中定义排名配置文件:

curl -s -d '{"yql":"select * from user where {\"targetHits\":10}nearestNeighbor(binary_code, q_binary_code);","ranking.features.query(q_binary_code)":[1,2,3,4,5,6,7,8,9,10],"hits":10, "ranking": "coarse-ranking"}' -H "Content-Type: application/json" -X POST http://localhost:8080/search/ | jq .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM