Information retrieval systems, an algebraic approach I