class_docstr: run search
class_docstr_tok: ["run","search"]
code: def extract_cases(self, collection):
      collection_name = (
          collection["collection_name"]
          if "collection_name" in collection
          else None
      )
      (
          data_type,
          collection_size,
          dimension,
          metric_type,
      ) = parser.collection_parser(collection_name)
      run_count = collection["run_count"]
      top_ks = collection["top_ks"]
      nqs = collection["nqs"]
      filters = collection["filters"] if "filters" in collection else []
      guarantee_timestamp = (
          collection["guarantee_timestamp"]
          if "guarantee_timestamp" in collection
          else None
      )
  
      search_params = collection["search_params"]
      # TODO: get fields by describe_index
      # fields = self.get_fields(self.milvus, collection_name)
      fields = None
      collection_info = {
          "dimension": dimension,
          "metric_type": metric_type,
          "dataset_name": collection_name,
          "collection_size": collection_size,
          "fields": fields,
      }
      # TODO: need to get index_info
      index_info = None
      vector_type = utils.get_vector_type(data_type)
      index_field_name = utils.get_default_field_name(vector_type)
      base_query_vectors = utils.get_vectors_from_binary(
          utils.MAX_NQ, dimension, data_type
      )
      cases = list()
      case_metrics = list()
      self.init_metric(self.name, collection_info, index_info, None)
      for search_param in search_params:
          logger.info("Search param: %s" % json.dumps(search_param))
          for filter in filters:
              filter_query = []
              filter_param = []
              if filter and isinstance(filter, dict):
                  if "range" in filter:
                      filter_query.append(eval(filter["range"]))
                      filter_param.append(filter["range"])
                  elif "term" in filter:
                      filter_query.append(eval(filter["term"]))
                      filter_param.append(filter["term"])
                  else:
                      raise Exception("%s not supported" % filter)
              logger.info("filter param: %s" % json.dumps(filter_param))
              for nq in nqs:
                  query_vectors = base_query_vectors[0:nq]
                  for top_k in top_ks:
                      search_info = {
                          "topk": top_k,
                          "query": query_vectors,
                          "metric_type": utils.metric_type_trans(
                              metric_type
                          ),
                          "params": search_param,
                      }
                      # TODO: only update search_info
                      case_metric = copy.deepcopy(self.metric)
                      case_metric.set_case_metric_type()
                      case_metric.search = {
                          "nq": nq,
                          "topk": top_k,
                          "search_param": search_param,
                          "filter": filter_param,
                          "guarantee_timestamp": guarantee_timestamp,
                      }
                      vector_query = {
                          "vector": {index_field_name: search_info}
                      }
                      case = {
                          "collection_name": collection_name,
                          "index_field_name": index_field_name,
                          "run_count": run_count,
                          "filter_query": filter_query,
                          "vector_query": vector_query,
                          "guarantee_timestamp": guarantee_timestamp,
                      }
                      cases.append(case)
                      case_metrics.append(case_metric)
      return cases, case_metrics
  
file_path: milvus/tests/benchmark/milvus_benchmark/runners/search.py
imports: import time
  import copy
  import json
  import logging
  from milvus_benchmark import parser
  from milvus_benchmark.runners import utils
  from milvus_benchmark.runners.base import BaseRunner
label_desc: Use image node_id 2 for calling the SearchRunner obj's underlying member method code with example usage: obj.extract_cases(collection) and returns: cases,  case_metrics