def OPTIMIZE(writer, segments):
 from whoosh.filedb.filereading import SegmentReader
 for seg in segments:
  reader = SegmentReader(writer.storage, writer.schema, seg)
  writer.add_reader(reader)
  reader.close()
 return []

def OPTIMIZE ( writer , segments ) : from whoosh . filedb . filereading import SegmentReader for seg in segments : reader = SegmentReader ( writer . storage , writer . schema , seg ) writer . add_reader ( reader ) reader . close ( ) return [ ]
this policy merges all existing segments .