Rank feature field type
editRank feature field type
editA rank_feature
field can index numbers so that they can later be used to boost
documents in queries with a rank_feature
query.
resp = client.indices.create( index="my-index-000001", mappings={ "properties": { "pagerank": { "type": "rank_feature" }, "url_length": { "type": "rank_feature", "positive_score_impact": False } } }, ) print(resp) resp1 = client.index( index="my-index-000001", id="1", document={ "pagerank": 8, "url_length": 22 }, ) print(resp1) resp2 = client.search( index="my-index-000001", query={ "rank_feature": { "field": "pagerank" } }, ) print(resp2)
response = client.indices.create( index: 'my-index-000001', body: { mappings: { properties: { pagerank: { type: 'rank_feature' }, url_length: { type: 'rank_feature', positive_score_impact: false } } } } ) puts response response = client.index( index: 'my-index-000001', id: 1, body: { pagerank: 8, url_length: 22 } ) puts response response = client.search( index: 'my-index-000001', body: { query: { rank_feature: { field: 'pagerank' } } } ) puts response
const response = await client.indices.create({ index: "my-index-000001", mappings: { properties: { pagerank: { type: "rank_feature", }, url_length: { type: "rank_feature", positive_score_impact: false, }, }, }, }); console.log(response); const response1 = await client.index({ index: "my-index-000001", id: 1, document: { pagerank: 8, url_length: 22, }, }); console.log(response1); const response2 = await client.search({ index: "my-index-000001", query: { rank_feature: { field: "pagerank", }, }, }); console.log(response2);
PUT my-index-000001 { "mappings": { "properties": { "pagerank": { "type": "rank_feature" }, "url_length": { "type": "rank_feature", "positive_score_impact": false } } } } PUT my-index-000001/_doc/1 { "pagerank": 8, "url_length": 22 } GET my-index-000001/_search { "query": { "rank_feature": { "field": "pagerank" } } }
Rank feature fields must use the |
|
Rank features that correlate negatively with the score need to declare it |
rank_feature
fields only support single-valued fields and strictly positive
values. Multi-valued fields and negative values will be rejected.
rank_feature
fields do not support querying, sorting or aggregating. They may
only be used within rank_feature
queries.
rank_feature
fields only preserve 9 significant bits for the precision, which
translates to a relative error of about 0.4%.
Rank features that correlate negatively with the score should set
positive_score_impact
to false
(defaults to true
). This will be used by
the rank_feature
query to modify the scoring formula
in such a way that the score decreases with the value of the feature instead of
increasing. For instance in web search, the url length is a commonly used
feature which correlates negatively with scores.