hunt-framework / hunt

A flexible, lightweight search platform
59 stars 10 forks source link

Add position to documents #95

Open chrisreu opened 10 years ago

chrisreu commented 10 years ago

I think it would be useful and make sense to add a position to the Documents

This is not necessary for the search itself, but for the front ends that should work with the retrieved Documents.

Consider a front-end that wants to render the Documents position, just like the hunt-server front-end right now. It needs the position data! For the demo i just added two extra fields to the general description.

Having a separate property would allow to write general functions for Document positions.

data Document = Document
  { uri   :: ! URI         -- ^ Unique identifier of the document.
  , desc  :: ! Description -- ^ Description of the document (simple key-value store).
  , wght  :: ! Score       -- ^ Weight used in ranking (default @1.0@).
  , pos   :: ! Maybe Position  -- ^ Optional document position
  }
  deriving (Show, Eq)