Searching documents from a custom search index
There are three ways you can search for a Solr document in Martini:
using functions, using a SolrClient
object, or using the Solr Search API.
Get the code!
The scripts mentioned in this guide are available in the examples
package.
As bonus, you can find other services in the examples
package that demonstrate
the use of functions from the SolrMethods
class,
as well as other Solr-related functionality.
Using functions
True to its purpose, using the function is the easiest way to update an existing document.
Functions from SolrMethods
in particular can help. For example:
1 2 3 |
|
Using SolrClient
A call to the function method SolrMethods.solr(String)
returns a
SolrClient
object which you can use to directly interact with
the Solr core tied to it (specified by passing the name of the core as the argument). However to use SolrClient
,
one must be familiar with SolrJ and Groovy.
1 2 |
|
Using the Solr Search API
Alternatively, you can use the extended Solr Search API to query documents. This will involve the use of Solr's SearchHandlers via the Solr-derived endpoint. For example:
1 2 3 |
|