For our first example, let’s consider a candiate generator that returns a list of pre-defined candidates. We first create our candidate-generator object.
(p-search-candidate-generator-create
:id 'p-search-candidate-generator-test
:name "TEST"
:input-spec '()
:options-spec '()
:function
(lambda (_args)
(list (p-search-documentize `(base ("Document 1" . "ABC\nDEF")))
(p-search-documentize `(base ("Document 2" . "GHI\nJKL")))
(p-search-documentize `(base ("Document 3" . "MNO\nPQR")))))
:lighter-function
(lambda (_args)
"test"))
Here we’re creating a candidate generator that returns a list of three documents. Recall that p-search-documentize is set up to know how to create documents of arying types with the p-search-def-property function, and the base type creates a document with name being the car and content being the cdr. If we wanted to generate candidates of type “file,” then we could make the following change:
(p-search-candidate-generator-create
:id 'p-search-candidate-generator-test
:name "TEST"
:input-spec '()
:options-spec '()
:function
(lambda (_args)
(list (p-search-documentize `(file "/path/to/file/1"))
(p-search-documentize `(file "/path/to/file/2"))
(p-search-documentize `(file "/path/to/file/3"))))
:lighter-function
(lambda (_args)
"test"))
This would create documents of type “file” which would have additional file-related properties.