class_docstr: Search structure which gives speedup at slight loss of recall.
  
  Uses cluster pruning structure as defined in:
  http://nlp.stanford.edu/IR-book/html/htmledition/cluster-pruning-1.html
  
  tldr - searching for a document in an index of K documents is naievely
      O(K). However you can create a tree structure where the first level
      is O(sqrt(K)) and each of the leaves are also O(sqrt(K)).
  
      You randomly pick sqrt(K) items to be in the top level. Then for
      the K doccuments you assign it to the closest neighbor in the top
      level.
  
      This breaks up one O(K) search into O(2 * sqrt(K)) searches which
      is much much faster when K is big.
  
      This generalizes to h levels. The runtime becomes:
          O(h * h_root(K))
class_docstr_tok: ["Search","structure","which","gives","speedup","at","slight","loss","of","recall",".","Uses","cluster","pruning","structure","as","defined","in",":","http",":","\/\/nlp.stanford.edu\/IR-book\/html\/htmledition\/cluster-pruning-1.html","tldr","-","searching","for","a","document","in","an","index","of","K","documents","is","naievely","O","(","K",")",".","However","you","can","create","a","tree","structure","where","the","first","level","is","O","(","sqrt","(","K",")",")","and","each","of","the","leaves","are","also","O","(","sqrt","(","K",")",")",".","You","randomly","pick","sqrt","(","K",")","items","to","be","in","the","top","level",".","Then","for","the","K","doccuments","you","assign","it","to","the","closest","neighbor","in","the","top","level",".","This","breaks","up","one","O","(","K",")","search","into","O","(","2","*","sqrt","(","K",")",")","searches","which","is","much","much","faster","when","K","is","big",".","This","generalizes","to","h","levels",".","The","runtime","becomes",":","O","(","h","*","h_root","(","K",")",")"]
docstr: Insert a single record into the index.
  
  Args:
      feature: feature vector
      record: record to return as the result of a search
docstr_tok: ["Insert","a","single","record","into","the","index",".","Args",":","feature",":","feature","vector","record",":","record","to","return","as","the","result","of","a","search"]
code: def insert(self, feature, record):
      """Insert a single record into the index.
  
      Args:
          feature: feature vector
          record: record to return as the result of a search
      """
      feature = self.distance_type.features_to_matrix(feature)
      nearest = self
      while not nearest.is_terminal:
          nearest = nearest.root.nearest_search(feature)
          _, nearest = nearest[0][0]
  
      cluster_index = nearest
      parent_index = cluster_index.parent
      while parent_index and cluster_index.matrix_size * 2 < len(
          cluster_index.root.get_records()
      ):
          cluster_index = parent_index
          parent_index = cluster_index.parent
  
      cluster_index._reindex(feature, record)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import collections
  import random
  import numpy
  import pysparnn.matrix_distance
label_desc: Use image node_id 2 for calling the ClusterIndex obj's underlying member method code with example usage: obj.insert(feature, record) without return types