固定查询
编辑固定查询
编辑将选定的文档提升到比匹配给定查询的文档更高的排名。此功能通常用于引导搜索者查看经过筛选的文档,这些文档会高于任何搜索的“自然”匹配项。提升或“固定”的文档使用存储在_id
字段中的文档 ID 进行标识。
示例请求
编辑resp = client.search( query={ "pinned": { "ids": [ "1", "4", "100" ], "organic": { "match": { "description": "iphone" } } } }, ) print(resp)
response = client.search( body: { query: { pinned: { ids: [ '1', '4', '100' ], organic: { match: { description: 'iphone' } } } } } ) puts response
const response = await client.search({ query: { pinned: { ids: ["1", "4", "100"], organic: { match: { description: "iphone", }, }, }, }, }); console.log(response);
GET /_search { "query": { "pinned": { "ids": [ "1", "4", "100" ], "organic": { "match": { "description": "iphone" } } } } }
pinned
的顶级参数
编辑在特定索引中固定文档
编辑如果你在多个索引上进行搜索,你可以使用 docs
在特定索引中固定一个文档
resp = client.search( query={ "pinned": { "docs": [ { "_index": "my-index-000001", "_id": "1" }, { "_id": "4" } ], "organic": { "match": { "description": "iphone" } } } }, ) print(resp)
response = client.search( body: { query: { pinned: { docs: [ { _index: 'my-index-000001', _id: '1' }, { _id: '4' } ], organic: { match: { description: 'iphone' } } } } } ) puts response
const response = await client.search({ query: { pinned: { docs: [ { _index: "my-index-000001", _id: "1", }, { _id: "4", }, ], organic: { match: { description: "iphone", }, }, }, }, }); console.log(response);