def MERGE_SMALL(writer, segments):
 from whoosh.filedb.filereading import SegmentReader
 newsegments = []
 sorted_segment_list = sorted(((s.doc_count_all(), s) for s in segments))
 total_docs = 0
 for (i, (count, seg)) in enumerate(sorted_segment_list):
  if (count > 0):
   total_docs += count
   if (total_docs < fib((i + 5))):
    reader = SegmentReader(writer.storage, writer.schema, seg)
    writer.add_reader(reader)
    reader.close()
   else:
    newsegments.append(seg)
 return newsegments

def MERGE_SMALL ( writer , segments ) : from whoosh . filedb . filereading import SegmentReader newsegments = [ ] sorted_segment_list = sorted ( ( ( s . doc_count_all ( ) , s ) for s in segments ) ) total_docs = 0 for ( i , ( count , seg ) ) in enumerate ( sorted_segment_list ) : if ( count > 0 ) : total_docs += count if ( total_docs < fib ( ( i + 5 ) ) ) : reader = SegmentReader ( writer . storage , writer . schema , seg ) writer . add_reader ( reader ) reader . close ( ) else : newsegments . append ( seg ) return newsegments
this policy merges small segments .