class_docstr: Group of functions related to elasticsearch filters
class_docstr_tok: ["Group","of","functions","related","to","elasticsearch","filters"]
docstr: Filter records by compound metadata
docstr_tok: ["Filter","records","by","compound","metadata"]
code: def metadata(
      metadata: Dict[str, Union[str, List[str]]]
  ) -> List[Dict[str, Any]]:
      """Filter records by compound metadata"""
      if not metadata:
          return []
  
      return [
          {
              "terms": {
                  f"metadata.{key}": query_text
                  if isinstance(query_text, List)
                  else [query_text]
              }
          }
          for key, query_text in metadata.items()
      ]
  
imports: from enum import Enum
  from typing import Any, Dict, List, Optional, Type, Union
  from argilla.server.commons.models import TaskStatus
  from argilla.server.daos.backend.mappings.helpers import mappings
  from argilla.server.pydantic_v1 import BaseModel
label_desc: Use image node_id 6 for calling the filters obj's underlying member method code with example usage: obj.metadata(metadata) and returns: unknown, list