database: Customize rank function for the search index.

database.PackageDocument is now merged into database.Package.
database.Package now implements search.FieldLoadSaver, which can
customize the Rank method to our default sorting algorithm. This allows
faster search queries by avoiding sorting. This also eliminates the
confusion of having two similar package structs in database.

Two admin handlers are used to reindex and purge index. These handlers
are restricted to be accessible to admin only in the yaml file.

Change-Id: I63929a50b08b9817e7d62020f9755fba9d4ec8f0
Reviewed-by: Alan Donovan <>
Reviewed-by: Andrew Gerrand <>
8 files changed