SilverStripe\Elastica\QueryGenerator
Synopsis
class QueryGenerator
{
- // members
- private string $queryText = '';
- private $fields = NULL;
- private $selectedFilters = NULL;
- private boolean $showResultsForEmptyQuery = false;
- private $manipulator = NULL;
- private integer $pageLength = 10;
- private integer $start = 0;
- private static integer $cacheHitCtr = 0;
- private string $classes = '';
- // methods
- public void setQueryText()
- public void setFields()
- public void setSelectedFilters()
- public void setShowResultsForEmptyQuery()
- public void getShowResultsForEmptyQuery()
- public void setPageLength()
- public void setStart()
- public void setClasses()
- public void setQueryResultManipulator()
- public static void getCacheHitCounter()
- public static void resetCacheHitCounter()
- public Query generateElasticaQuery()
- public Query generateElasticaAutocompleteQuery()
- private void addFilters()
- private void addAggregation()
- private void simpleTextQuery()
- private void multiMatchQuery()
- public array convertWeightedFieldsForElastica()
- public static array getSearchFieldsMappingForClasses()
- public static void getCache()
- public static string convertToQuotedCSV()
Members
private
- $cacheHitCtr
- $classes
—
string
Comma separated list of SilverStripe ClassNames to search. Leave blank for all. - $fields
- $manipulator
- $pageLength
- $queryText
- $selectedFilters
- $showResultsForEmptyQuery
- $start
Methods
private
- addAggregation()
- addFilters() — Using a query string object, return a suitable filtered or unfiltered query object.
- multiMatchQuery()
- simpleTextQuery()
public
- convertToQuotedCSV() — Convert either a CSV string or an array to a CSV single quoted string, suitable for use in an SQL IN clause.
- convertWeightedFieldsForElastica() — Use the configuration from the Search settings held in the database to form the array of fields suitable for a multimatch query. Call this after having called setClasses.
- generateElasticaAutocompleteQuery() — Generate a query for autocomplete.
- generateElasticaQuery() — From the input variables create a suitable query using Elastica. This is somewhat complex due to different formats with and without query text, with and without filters, with and without selected filters. Extracting this logic into a separate class makes testing much faster and can be used for testing new cases.
- getCache()
- getCacheHitCounter()
- getSearchFieldsMappingForClasses() — Get a hash of name to Elasticserver mapping, e.g. 'Title' => 'string' Use SS_Cache to save on database hits, as this data only changes at build time.
- getShowResultsForEmptyQuery()
- resetCacheHitCounter()
- setClasses() — Update the list of Classes to search, use SilverStripe ClassName comma separated.
- setFields()
- setPageLength()
- setQueryResultManipulator() — Set the manipulator, mainly used for aggregation.
- setQueryText()
- setSelectedFilters()
- setShowResultsForEmptyQuery()
- setStart()