class_docstr: Base class for storing and searching image signatures in a database
  
  Note:
      You must implement the methods search_single_record and insert_single_record
      in a derived class
docstr: Search for a matching image record.
  
  Must be implemented by derived class.
  
  Args:
      rec (dict): an image record. Will be in the format returned by
          make_record
  
          For example, rec could have the form:
  
          {'path': 'https://pixabay.com/static/uploads/photo/2012/11/28/08/56/mona-lisa-67506_960_720.jpg',
           'signature': [0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 0 ... ]
           'simple_word_0': 42252475,
           'simple_word_1': 23885671,
           'simple_word_10': 9967839,
           'simple_word_11': 4257902,
           'simple_word_12': 28651959,
           'simple_word_13': 33773597,
           'simple_word_14': 39331441,
           'simple_word_15': 39327300,
           'simple_word_16': 11337345,
           'simple_word_17': 9571961,
           'simple_word_18': 28697868,
           'simple_word_19': 14834907,
           'simple_word_2': 7434746,
           'simple_word_20': 37985525,
           'simple_word_21': 10753207,
           'simple_word_22': 9566120,
           ...
           'metadata': {'category': 'art'},
           }
  
           The number of simple words corresponds to the attribute N
  
      pre_filter (dict): a filter to be applied by the concrete implementation
             before applying the matching strategy
  
          For example:
              { "term": {  "image.metadata.category": "art" } }
  
  Returns:
      a formatted list of dicts representing matches.
  
      For example, if three matches are found:
  
      [
       {'dist': 0.069116439263706961,
        'id': u'AVM37oZq0osmmAxpPvx7',
        'path': u'https://pixabay.com/static/uploads/photo/2012/11/28/08/56/mona-lisa-67506_960_720.jpg'},
       {'dist': 0.22484320805049718,
        'id': u'AVM37nMg0osmmAxpPvx6',
        'path': u'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg/687px-Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg'},
       {'dist': 0.42529792112113302,
        'id': u'AVM37p530osmmAxpPvx9',
        'metadata': {...},
        'path': u'https://c2.staticflickr.com/8/7158/6814444991_08d82de57e_z.jpg'}
      ]
  
      You can return any fields you like, but must include at least dist and id. Duplicate entries are ok,
      and they do not need to be sorted
docstr_tok: ["Search","for","a","matching","image","record",".","Must","be","implemented","by","derived","class",".","Args",":","rec","(","dict",")",":","an","image","record",".","Will","be","in","the","format","returned","by","make_record","For","example",",","rec","could","have","the","form",":","{","'path","'",":","'https",":","\/\/pixabay.com\/static\/uploads\/photo\/2012\/11\/28\/08\/56\/mona-lisa-67506_960_720.jpg","'",",","'signature","'",":","[","0",",","0",",","0",",","0",",","0",",","0",",","2",",","2",",","0",",","0",",","0",",","0",",","0",",","2",",","2",",","2",",","0",",","0",",","0",",","0",",","2",",","2",",","2",",","2",",","0","...","]","'simple_word_0","'",":","42252475",",","'simple_word_1","'",":","23885671",",","'simple_word_10","'",":","9967839",",","'simple_word_11","'",":","4257902",",","'simple_word_12","'",":","28651959",",","'simple_word_13","'",":","33773597",",","'simple_word_14","'",":","39331441",",","'simple_word_15","'",":","39327300",",","'simple_word_16","'",":","11337345",",","'simple_word_17","'",":","9571961",",","'simple_word_18","'",":","28697868",",","'simple_word_19","'",":","14834907",",","'simple_word_2","'",":","7434746",",","'simple_word_20","'",":","37985525",",","'simple_word_21","'",":","10753207",",","'simple_word_22","'",":","9566120",",","...","'metadata","'",":","{","'category","'",":","'art","'","}",",","}","The","number","of","simple","words","corresponds","to","the","attribute","N","pre_filter","(","dict",")",":","a","filter","to","be","applied","by","the","concrete","implementation","before","applying","the","matching","strategy","For","example",":","{","``","term","''",":","{","``","image.metadata.category","''",":","``","art","''","}","}","Returns",":","a","formatted","list","of","dicts","representing","matches",".","For","example",",","if","three","matches","are","found",":","[","{","'dist","'",":","0.069116439263706961",",","'id","'",":","u'AVM37oZq0osmmAxpPvx7","'",",","'path","'",":","u'https",":","\/\/pixabay.com\/static\/uploads\/photo\/2012\/11\/28\/08\/56\/mona-lisa-67506_960_720.jpg","'","}",",","{","'dist","'",":","0.22484320805049718",",","'id","'",":","u'AVM37nMg0osmmAxpPvx6","'",",","'path","'",":","u'https",":","\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/e\/ec\/Mona_Lisa",",","_by_Leonardo_da_Vinci",",","_from_C2RMF_retouched.jpg\/687px-Mona_Lisa",",","_by_Leonardo_da_Vinci",",","_from_C2RMF_retouched.jpg","'","}",",","{","'dist","'",":","0.42529792112113302",",","'id","'",":","u'AVM37p530osmmAxpPvx9","'",",","'metadata","'",":","{","...","}",",","'path","'",":","u'https",":","\/\/c2.staticflickr.com\/8\/7158\/6814444991_08d82de57e_z.jpg","'","}","]","You","can","return","any","fields","you","like",",","but","must","include","at","least","dist","and","id",".","Duplicate","entries","are","ok",",","and","they","do","not","need","to","be","sorted"]
code: def search_single_record(self, rec, pre_filter=None):
      """Search for a matching image record.
  
      Must be implemented by derived class.
  
      Args:
          rec (dict): an image record. Will be in the format returned by
              make_record
  
              For example, rec could have the form:
  
              {'path': 'https://pixabay.com/static/uploads/photo/2012/11/28/08/56/mona-lisa-67506_960_720.jpg',
               'signature': [0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 0 ... ]
               'simple_word_0': 42252475,
               'simple_word_1': 23885671,
               'simple_word_10': 9967839,
               'simple_word_11': 4257902,
               'simple_word_12': 28651959,
               'simple_word_13': 33773597,
               'simple_word_14': 39331441,
               'simple_word_15': 39327300,
               'simple_word_16': 11337345,
               'simple_word_17': 9571961,
               'simple_word_18': 28697868,
               'simple_word_19': 14834907,
               'simple_word_2': 7434746,
               'simple_word_20': 37985525,
               'simple_word_21': 10753207,
               'simple_word_22': 9566120,
               ...
               'metadata': {'category': 'art'},
               }
  
               The number of simple words corresponds to the attribute N
  
          pre_filter (dict): a filter to be applied by the concrete implementation
                 before applying the matching strategy
  
              For example:
                  { "term": {  "image.metadata.category": "art" } }
  
      Returns:
          a formatted list of dicts representing matches.
  
          For example, if three matches are found:
  
          [
           {'dist': 0.069116439263706961,
            'id': u'AVM37oZq0osmmAxpPvx7',
            'path': u'https://pixabay.com/static/uploads/photo/2012/11/28/08/56/mona-lisa-67506_960_720.jpg'},
           {'dist': 0.22484320805049718,
            'id': u'AVM37nMg0osmmAxpPvx6',
            'path': u'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg/687px-Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg'},
           {'dist': 0.42529792112113302,
            'id': u'AVM37p530osmmAxpPvx9',
            'metadata': {...},
            'path': u'https://c2.staticflickr.com/8/7158/6814444991_08d82de57e_z.jpg'}
          ]
  
          You can return any fields you like, but must include at least dist and id. Duplicate entries are ok,
          and they do not need to be sorted
  
      """
      raise NotImplementedError
  
file_path: image-match/image_match/signature_database_base.py
imports: from image_match.goldberg import ImageSignature
  from itertools import product
  from operator import itemgetter
  import numpy
label_desc: Use image node_id 1 for calling the SignatureDatabaseBase obj's underlying member method code with example usage: obj.search_single_record(rec, pre_filter) without return types