\SolrSearchService
A search service built around Solr
- Author: Marcus Nyeholt <marcus@silverstripe.com.au>
- License: http://silverstripe.org/bsd-license/
Synopsis
class SolrSearchService
{
- // constants
- const RAW_DATA_KEY = 'SOLRRAWDATA_';
- const SERIALIZED_OBJECT = 'raw_dataobject';
- // members
- public static string $config_file = 'solr/config';
- public static string $java_bin = '/usr/bin/java';
- public static array $solr_details = ;
- public static array $default_query_fields = ;
- public static String $mapper_class = 'SolrSchemaMapper';
- public Apache_Solr_HttpTransport_Interface $solrTransport;
- public Apache_Solr_Service $client;
- protected SolrSchemaMapper $mapper;
- protected Zend_Cache_Core $cache;
- protected integer $cacheTime = 3600;
- protected map $queryBuilders = ;
- protected array $searchableCache = ;
- // methods
- public void __construct()
- public void setCache()
- public boolean isConnected()
- public void setMapper()
- public void add_default_query_field()
- public void addQueryBuilder()
- public array getQueryBuilders()
- public SolrQueryBuilder getQueryBuilder()
- public void index()
- public void indexMultiple()
- public void convertObjectToDocument()
- protected void getParentsHierarchyField()
- protected array objectToFields()
- public void unindex()
- public void parseSearch()
- public SolrResultSet query()
- public void getFacetsForFields()
- public Apache_Solr_Service getSolr()
- public void getSearchableFieldsFor()
- public void getAllSearchableFieldsFor()
- protected void buildSearchableFieldCache()
- public String getSolrFieldName()
- public void getSortFieldName()
- public void localEngineConfig()
- public void localEngineStatus()
- public void startSolr()
- public void stopSolr()
- public void saveEngineConfig()
- public void getLogData()
- protected void tail()
Tasks
Line | Task |
---|---|
281 | we want to genercise this later for other modules to hook into it! |
Constants
Name | Value |
---|---|
RAW_DATA_KEY | 'SOLRRAWDATA_' |
SERIALIZED_OBJECT | 'raw_dataobject' |
Members
protected
- $cache
—
Zend_Cache_Core
A cache object for query caching - $cacheTime
—
int
How many seconds to cache results for - $mapper
—
SolrSchemaMapper
The mapper to use to map silverstripe objects to a solr schema - $queryBuilders
—
map
A mapping of all the available query builders - $searchableCache
public
- $client
—
Apache_Solr_Service
The underlying query transport api - $config_file
- $default_query_fields
—
array
A list of all fields that will be searched through by default, if the user hasn't specified any in their search query. - $java_bin
- $mapper_class
—
String
Determines what mapper class to use to map to solr schema fields. - $solrTransport
—
Apache_Solr_HttpTransport_Interface
The Solr transport to use if needed - $solr_details
—
array
The connection details for the solr instance to connect to
Methods
protected
- buildSearchableFieldCache() — Builds up the searchable fields configuration baased on the solrtypeconfiguration objects
- getParentsHierarchyField() — Get a solr field representing the parents hierarchy (if applicable)
- objectToFields() — Pull out all the fields that should be indexed for a particular object
- tail()
public
- __construct()
- addQueryBuilder() — Add a new query parser into the service
- add_default_query_field() — Add a field to be included in default searches
- convertObjectToDocument()
- getAllSearchableFieldsFor() — Get all the searchable fields for a given set of classes
- getFacetsForFields() — Method used to return details about the facets stored for content, if any, for an empty query.
- getLogData()
- getQueryBuilder() — Gets the query builder for the given search type
- getQueryBuilders() — Gets the list of query parsers available
- getSearchableFieldsFor() — Get all the fields that can be indexed / searched on for a particular type
- getSolr() — Get the solr service client
- getSolrFieldName() — Return the field name for a given property within a given set of data object types
- getSortFieldName() — Get a field name used for sorting in a query. This is just a hardcoded way at the moment to handle the fact that to sort by 'Title', you actually want to sort by title_exact (due to tokenization in solr).
- index() — Assuming here that we're indexing a stdClass object with an ID field that is a unique identifier
- indexMultiple()
- isConnected() — Is solr alive?
- localEngineConfig() — get local service information
- localEngineStatus()
- parseSearch() — Parse a raw user search string into a query appropriate for execution.
- query() — Perform a raw query against the search index, returning a SolrResultSet object that can be used to extract a more complete result set
- saveEngineConfig()
- setCache()
- setMapper() — A class that can map field types to solr fields, and values to appropriate types
- startSolr()
- stopSolr()
- unindex() — Delete a data object from the index