include/SugarSearchEngine/Elastic/SugarSearchEngineElastic.php
\SugarSearchEngineElastic
Engine implementation for ElasticSearch
Constants
MAX_BULK_THRESHOLD
= 100
The max number of documents to bulk insert at a time
Inherited from: \SugarSearchEngineAbstractBase::MAX_BULK_THRESHOLD- Inherited_from
- \SugarSearchEngineAbstractBase::MAX_BULK_THRESHOLD
Properties
array
$_documents= 'array()'
array()
Details- Type
- array
- Inherited_from
- \SugarSearchEngineAbstractBase::$$_documents
Methods
__destruct(
)
:
void
Bulk insert any documents that have been marked for bulk insertion.
Inherited from: \SugarSearchEngineAbstractBase::__destruct()__wakeup(
)
:
void
This is needed to prevent unserialize vulnerability
Inherited from: \SugarSearchEngineAbstractBase::__wakeup()addRecordsToQueue(
\$records $records
)
:
void
This function adds records to FTS queue.
Inherited from: \SugarSearchEngineAbstractBase::addRecordsToQueue()Name | Type | Description |
---|---|---|
$records | \$records | array of records |
canAppendWildcard(
String $queryString
)
:
Boolean
This function determines whether we should append wildcard to search string.
Name | Type | Description |
---|---|---|
$queryString | String |
Type | Description |
---|---|
Boolean |
checkException(
\$e $e
)
:
boolean
Check if this is an Elastic client exception, disable FTS if it is
Name | Type | Description |
---|---|---|
$e | \$e | Exception |
Type | Description |
---|---|
boolean | tru if it's an Elastic client exception, false otherwise |
cleanTeamSetID(
$teamSetID
)
:
mixed
Remove the '-' from our team sets.
Name | Type | Description |
---|---|---|
$teamSetID |
Type | Description |
---|---|
mixed |
constructHighlightArray(
$fields, $options
)
:
\Elastica_Document | null
Given fields and options, this function constructs and returns a highlight array that can be passed to search engine.
Name | Type | Description |
---|---|---|
$fields | ||
$options |
Type | Description |
---|---|
\Elastica_Document | null |
constructMainFilter(
$finalTypes
)
:
\Elastica_Filter_Or
This function constructs and returns main filter for elasticsearch query.
Name | Type | Description |
---|---|---|
$finalTypes |
Type | Description |
---|---|
\Elastica_Filter_Or |
constructModuleLevelFilter(
$module
)
:
\Elastica_Filter_And
This function constructs and returns module level filter for elasticsearch query.
Name | Type | Description |
---|---|---|
$module |
Type | Description |
---|---|
\Elastica_Filter_And |
constructTeamFilter(
)
:
\Elastica_Filter_Or
This function constructs and returns team filter for elasticsearch query.
Type | Description |
---|---|
\Elastica_Filter_Or |
createIndex(
boolean $recreate
=
false
)
:
void
Create the index and mapping.
Name | Type | Description |
---|---|---|
$recreate | boolean | OPTIONAL Deletes index first if already exists (default = false) |
createIndexDocument(
\SugarBean $bean, $searchFields
=
null
)
:
\Elastica_Document | null
Name | Type | Description |
---|---|---|
$bean | \SugarBean | |
$searchFields |
Type | Description |
---|---|
\Elastica_Document | null |
disableFTS(
)
:
void
Disable FTS and write to config.
Inherited from: \SugarSearchEngineAbstractBase::disableFTS()getIndexType(
$bean
)
:
string
Return the 'type' for the index. By using the bean type we can specify mappings on a per bean basis if we need to in the future.
Name | Type | Description |
---|---|---|
$bean |
Type | Description |
---|---|
string |
getOwnerField(
\SugarBean $bean
)
:
String
Name | Type | Description |
---|---|---|
$bean | \SugarBean |
Type | Description |
---|---|
String | owner, or null if no owner found |
getOwnerTermFilter(
)
:
\Elastica_Filter_Term
This function constructs and returns owner term filter for elasticsearch query.
Type | Description |
---|---|
\Elastica_Filter_Term |
getRecordsFromDocs(
$docs
)
:
array
Given an array of documents, this constructs an array of records that can be saved to FTS queue.
Name | Type | Description |
---|---|---|
$docs |
Type | Description |
---|---|
array |
getSearchFields(
Array $options
)
:
Array
This function returns an array of fields that can be passed to search engine.
Name | Type | Description |
---|---|---|
$options | Array |
Type | Description |
---|---|
Array | array of fields |
getTypeTermFilter(
$module
)
:
\Elastica_Filter_Term
This function constructs and returns type term filter for elasticsearch query.
Name | Type | Description |
---|---|---|
$module |
Type | Description |
---|---|
\Elastica_Filter_Term |
indexBean(
\$bean $bean, \$batch $batch
=
TRUE
)
:
void
Either index single bean or add the record to be indexed into _documents for later batch indexing, depending on the $batch parameter
Name | Type | Description |
---|---|---|
$bean | \$bean | SugarBean object to be indexed |
$batch | \$batch | boolean whether to do batch index |
indexSingleBean(
\SugarBean $bean
)
:
void
This indexes one single bean to Elastic Search engine
Name | Type | Description |
---|---|---|
$bean | \SugarBean |
isModuleFtsEnabled(
$module
)
:
bool
Determine if a module is FTS enabled.
Inherited from: \SugarSearchEngineAbstractBase::isModuleFtsEnabled()Name | Type | Description |
---|---|---|
$module |
Type | Description |
---|---|
bool |
isSearchEngineDown(
)
:
Boolean
This function checks config to see if search engine is down.
Inherited from: \SugarSearchEngineAbstractBase::isSearchEngineDown()Type | Description |
---|---|
Boolean |
loader(
$className
)
:
mixed
This function loads the desired file/class from Elastic directory.
Name | Type | Description |
---|---|---|
$className |
Type | Description |
---|---|
mixed |
markSearchEngineStatus(
Boolean $isDown
=
true
)
:
void
This function marks config to indicate that search engine is up or down.
Inherited from: \SugarSearchEngineAbstractBase::markSearchEngineStatus()Name | Type | Description |
---|---|---|
$isDown | Boolean |
search(
$queryString, int $offset
=
0, int $limit
=
20, $options
=
array()
)
:
null | \SugarSeachEngineElasticResultSet
Name | Type | Description |
---|---|---|
$queryString | ||
$offset | int | |
$limit | int | |
$options |
Type | Description |
---|---|
null | \SugarSeachEngineElasticResultSet |