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"
code: def _validate_params(
      self,
      weight: float,
      top_k: Optional[int],
      ranking_mode: Literal["reciprocal_rank_fusion", "linear_score"],
      sort_order: Literal["ascending", "descending"],
  ):
      if top_k is not None and top_k <= 0:
          raise ValueError("top_k must be > 0, but got %s" % top_k)
  
      if weight < 0 or weight > 1:
          raise ValueError(
              "Parameter <weight> must be in range [0,1] but is currently set to '%s'.\n'0' disables sorting by a "
              "meta field, '0.5' assigns equal weight to the previous relevance scores and the meta field, and "
              "'1' ranks by the meta field only.\nChange the <weight> parameter to a value in range 0 to 1 when "
              "initializing the MetaFieldRanker." % self.weight
          )
  
      if ranking_mode not in ["reciprocal_rank_fusion", "linear_score"]:
          raise ValueError(
              "The value of parameter <ranking_mode> must be 'reciprocal_rank_fusion' or 'linear_score', but is "
              "currently set to '%s'.\nChange the <ranking_mode> value to 'reciprocal_rank_fusion' or "
              "'linear_score' when initializing the MetaFieldRanker."
              % ranking_mode
          )
  
      if sort_order not in ["ascending", "descending"]:
          raise ValueError(
              "The value of parameter <sort_order> must be 'ascending' or 'descending', but is currently set to '%s'.\n"
              "Change the <sort_order> value to 'ascending' or 'descending' when initializing the "
              "MetaFieldRanker." % 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 2 for calling the MetaFieldRanker obj's underlying member method code with example usage: obj._validate_params(weight, top_k, ranking_mode, sort_order) without return types