class_docstr: Ranks Documents based on the value of their specific meta field.
  The ranking can be performed in descending order or ascending order.
  
  Usage example:
  ```
  from haystack import Document
  from haystack.components.rankers import MetaFieldRanker
  
  ranker = MetaFieldRanker(meta_field="rating")
  docs = [
      Document(text="Paris", meta={"rating": 1.3}),
      Document(text="Berlin", meta={"rating": 0.7}),
      Document(text="Barcelona", meta={"rating": 2.1}),
  ]
  
  output = ranker.run(documents=docs)
  docs = output["documents"]
  assert docs[0].text == "Barcelona"
docstr: Creates an instance of MetaFieldRanker.
  
  :param meta_field: The name of the meta field to rank by.
  :param weight: In range [0,1].
          0 disables ranking by a meta field.
          0.5 content and meta fields have the same impact for the ranking.
          1 means ranking by a meta field only. The highest value comes first.
  :param top_k: The maximum number of Documents you want the Ranker to return per query. If not provided, the
          Ranker returns all documents it receives in the new ranking order.
  :param ranking_mode: The mode used to combine the Retriever's and Ranker's scores.
          Possible values are 'reciprocal_rank_fusion' (default) and 'linear_score'.
          Use the 'score' mode only with Retrievers or Rankers that return a score in range [0,1].
  :param sort_order: Whether to sort the meta field by ascending or descending order.
          Possible values are `descending` (default) and `ascending`.
code: def __init__(
      self,
      meta_field: str,
      weight: float = 1.0,
      top_k: Optional[int] = None,
      ranking_mode: Literal[
          "reciprocal_rank_fusion", "linear_score"
      ] = "reciprocal_rank_fusion",
      sort_order: Literal["ascending", "descending"] = "descending",
  ):
      """
      Creates an instance of MetaFieldRanker.
  
      :param meta_field: The name of the meta field to rank by.
      :param weight: In range [0,1].
              0 disables ranking by a meta field.
              0.5 content and meta fields have the same impact for the ranking.
              1 means ranking by a meta field only. The highest value comes first.
      :param top_k: The maximum number of Documents you want the Ranker to return per query. If not provided, the
              Ranker returns all documents it receives in the new ranking order.
      :param ranking_mode: The mode used to combine the Retriever's and Ranker's scores.
              Possible values are 'reciprocal_rank_fusion' (default) and 'linear_score'.
              Use the 'score' mode only with Retrievers or Rankers that return a score in range [0,1].
      :param sort_order: Whether to sort the meta field by ascending or descending order.
              Possible values are `descending` (default) and `ascending`.
      """
  
      self.meta_field = meta_field
      self.weight = weight
      self.top_k = top_k
      self.ranking_mode = ranking_mode
      self.sort_order = sort_order
      self._validate_params(
          weight=self.weight,
          top_k=self.top_k,
          ranking_mode=self.ranking_mode,
          sort_order=self.sort_order,
      )
  
file_path: haystack/haystack/components/rankers/meta_field.py
imports: import logging
  from collections import defaultdict
  from typing import List, Dict, Any, Optional, Literal
  from haystack import Document, component, default_to_dict
label_desc: Use image node_id 1 to create a new MetaFieldRanker object  with example: obj = MetaFieldRanker(meta_field, weight, top_k, ranking_mode, sort_order)