docstr: target: test compact and create index
  method: 1.insert data into two segments
          2.compact
          3.create index
          4.load and search
  expected: Verify search result and index info
docstr_tok: ["target",":","test","compact","and","create","index","method",":","1.insert","data","into","two","segments","2.compact","3.create","index","4.load","and","search","expected",":","Verify","search","result","and","index","info"]
code: def test_compact_and_index(self):
      """
      target: test compact and create index
      method: 1.insert data into two segments
              2.compact
              3.create index
              4.load and search
      expected: Verify search result and index info
      """
      pytest.skip("Compaction requires segment indexed")
      collection_w = self.collection_insert_multi_segments_one_shard(
          prefix, nb_of_segment=ct.default_nb, is_dup=False
      )
  
      # compact
      collection_w.compact()
      collection_w.wait_for_compaction_completed()
      collection_w.get_compaction_plans(
          check_task=CheckTasks.check_merge_compact
      )
  
      # create index
      collection_w.create_index(
          ct.default_float_vec_field_name, ct.default_index
      )
      log.debug(collection_w.index())
  
      # search
      collection_w.load()
      search_res, _ = collection_w.search(
          cf.gen_vectors(ct.default_nq, ct.default_dim),
          ct.default_float_vec_field_name,
          ct.default_search_params,
          ct.default_limit,
      )
      assert len(search_res) == ct.default_nq
      for hits in search_res:
          assert len(hits) == ct.default_limit
  
imports: import threading
  from time import time, sleep
  import pytest
  from pymilvus.grpc_gen.common_pb2 import SegmentState
  from pymilvus.exceptions import MilvusException
  from base.client_base import TestcaseBase
  from common import common_func
  from common import common_type
  from common.common_type import CaseLabel, CheckTasks
  from utils.util_log import test_log
label_desc: Use image node_id 6 for calling the TestCompactionOperation obj's underlying member method code with example usage: obj.test_compact_and_index() without return types