code: def test_object_as_string_fresh(batch=True):
      space_type = "cosinesimil"
      space_param = []
      method_name = "small_world_rand"
      index_name = method_name + ".index"
      if os.path.isfile(index_name):
          os.remove(index_name)
      index = nmslib.init(
          space_type,
          space_param,
          method_name,
          nmslib.DataType.OBJECT_AS_STRING,
          nmslib.DistType.FLOAT,
      )
  
      if batch:
          data = [s for s in read_data_as_string("sample_dataset.txt")]
          positions = nmslib.addDataPointBatch(
              index, np.arange(len(data), dtype=np.int32), data
          )
      else:
          for id, data in enumerate(
              read_data_as_string("sample_dataset.txt")
          ):
              nmslib.addDataPoint(index, id, data)
  
      print("Let's print a few data entries")
      print(
          "We have added %d data points" % nmslib.getDataPointQty(index)
      )
  
      for i in range(
          0, min(MAX_PRINT_QTY, nmslib.getDataPointQty(index))
      ):
          print(nmslib.getDataPoint(index, i))
  
      print("Let's invoke the index-build process")
  
      index_param = ["NN=17", "efConstruction=50", "indexThreadQty=4"]
      query_time_param = ["efSearch=50"]
  
      nmslib.createIndex(index, index_param)
  
      print("The index is created")
  
      nmslib.setQueryTimeParams(index, query_time_param)
  
      print("Query time parameters are set")
  
      print("Results for the freshly created index:")
  
      k = 3
  
      for idx, data in enumerate(
          read_data_as_string("sample_queryset.txt")
      ):
          print(idx, nmslib.knnQuery(index, k, data))
  
      nmslib.saveIndex(index, index_name)
  
      print("The index %s is saved" % index_name)
  
      nmslib.freeIndex(index)
  
file_path: nmslib/python_bindings/integration_tests/test_nmslib.py
imports: import sys
  import os
  import time
  import numpy
  import nmslib
  from common import *
label_desc: Use image node_id 13 for calling a global function with example usage: test_object_as_string_fresh(batch) without return types