code: def do_search(self, window, freshlen):
      spawn = self.spawn
      searcher = self.searcher
      if freshlen > len(window):
          freshlen = len(window)
      index = searcher.search(window, freshlen, self.searchwindowsize)
      if index >= 0:
          spawn._buffer = spawn.buffer_type()
          spawn._buffer.write(window[searcher.end :])
          spawn.before = spawn._before.getvalue()[
              0 : -(len(window) - searcher.start)
          ]
          spawn._before = spawn.buffer_type()
          spawn._before.write(window[searcher.end :])
          spawn.after = window[searcher.start : searcher.end]
          spawn.match = searcher.match
          spawn.match_index = index
          # Found a match
          return index
      elif self.searchwindowsize or self.lookback:
          maintain = self.searchwindowsize or self.lookback
          if spawn._buffer.tell() > maintain:
              spawn._buffer = spawn.buffer_type()
              spawn._buffer.write(window[-maintain:])
  
imports: import time
  from .exceptions import EOF, TIMEOUT
label_desc: Use image node_id 2 for calling the Expecter obj's underlying member method code with example usage: obj.do_search(window, freshlen) and returns: index