(writer, segments)
return newsegments
This policy merges small segments, where "small" is defined using a
    heuristic based on the fibonacci sequence.
This policy merges small segments, where "small" is defined using a
    heuristic based on the fibonacci sequence.
This policy merges small segments where small is defined using a heuristic based on the fibonacci sequence .
def MERGE_SMALL(writer, segments):
    """This policy merges small segments, where "small" is defined using a
    heuristic based on the fibonacci sequence.
    """

    from whoosh.reading import SegmentReader

    newsegments = []
    sorted_segment_list = sorted(segments, key=lambda s: s.doc_count_all())
    total_docs = 0
    for i, seg in enumerate(sorted_segment_list):
        count = seg.doc_count_all()
        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 . reading import SegmentReader newsegments = [ ] sorted_segment_list = sorted ( segments , key = lambda s : s . doc_count_all ( ) ) total_docs = 0 for i , seg in enumerate ( sorted_segment_list ) : count = seg . doc_count_all ( ) 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