Extract item search functions into a separate module

For ease of testing and likely re-use in the web UI later,
extract them out of the cli module.