5.1.1 A Note on Properties and Fields

p-search’s internals have two concepts which might be confused with eachother: properies and fields. Properties, usually defined with p-search-def-property, define what a document is. The fields are just a property on the document, specifying generic things that can be searched on.

For example, a database connection object or buffer object could be a candidate’s property if the document is related to searching in a database. The database connection wouldn’t be a field though, since it’s not something that can be generically searched on. A document’s title or subtitle would be good fields however, as a user may want to search on these.

Suppose we want to create a search candidate for Emacs windows, searching the text visible in each window across all frames. In this case, we may have a property called window and set it to the window object, because that’s what the search candidate is.

Arbitrary properties and fields can be defined, though there is a number of built-in items. Each candidate must have the name and content properties. file-name is another commonly used property, which is the full file path if a seach candidate is derived from a file. As for built-in fields, title, author, keywords, creation-date, modification-date, language, and file-type can be used without having to define them with p-search-def-field.