1.2 Candidate Mappings

Unfortunately, many searches can’t be reduced to a search on an operating system’s file system. As a simple example, suppose you write all of your notes in one large org-mode file. The document may have thousands of sections in it. A filesystem search obviously won’t help you here as the candidate you want, while derived from a OS file, isn’t the file itself, but rather a section of the file. Or suppose you use Denote for managing your notes and do want individual files, but you want to be able to search on the file’s name alone.

There are many cases where you’ll want to add search criteria to an already existing search candidate and “mappings” in p-search allow you to do this. A mapping in p-search is essentially a function that takes a document (defined by key-value properties) and returns an expanded document, with perhaps new properties and fields to search on. This in turn allows for a high level composability between various components, allowing you to mix and match what particular details you’re interested in searching on.