include/SugarSearchEngine/Elastic/SugarSearchEngineElastic.php
\SugarSearchEngineElastic
Engine implementation for ElasticSearch
Constants
MAX_BULK_THRESHOLD
= 100The 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(
)
:
voidBulk insert any documents that have been marked for bulk insertion.
Inherited from: \SugarSearchEngineAbstractBase::__destruct()
__wakeup(
)
:
voidThis is needed to prevent unserialize vulnerability
Inherited from: \SugarSearchEngineAbstractBase::__wakeup()
addRecordsToQueue(
\$records $records
)
:
voidThis function adds records to FTS queue.
Inherited from: \SugarSearchEngineAbstractBase::addRecordsToQueue()| Name | Type | Description |
|---|---|---|
| $records | \$records | array of records |

canAppendWildcard(
String $queryString
)
:
BooleanThis function determines whether we should append wildcard to search string.
| Name | Type | Description |
|---|---|---|
| $queryString | String |
| Type | Description |
|---|---|
| Boolean |

checkException(
\$e $e
)
:
booleanCheck 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
)
:
mixedRemove the '-' from our team sets.
| Name | Type | Description |
|---|---|---|
| $teamSetID |
| Type | Description |
|---|---|
| mixed |

constructHighlightArray(
$fields, $options
)
:
\Elastica_Document | nullGiven 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_OrThis function constructs and returns main filter for elasticsearch query.
| Name | Type | Description |
|---|---|---|
| $finalTypes |
| Type | Description |
|---|---|
| \Elastica_Filter_Or |

constructModuleLevelFilter(
$module
)
:
\Elastica_Filter_AndThis function constructs and returns module level filter for elasticsearch query.
| Name | Type | Description |
|---|---|---|
| $module |
| Type | Description |
|---|---|
| \Elastica_Filter_And |

constructTeamFilter(
)
:
\Elastica_Filter_OrThis function constructs and returns team filter for elasticsearch query.
| Type | Description |
|---|---|
| \Elastica_Filter_Or |

createIndex(
boolean $recreate
=
false
)
:
voidCreate 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(
)
:
voidDisable FTS and write to config.
Inherited from: \SugarSearchEngineAbstractBase::disableFTS()
getIndexType(
$bean
)
:
stringReturn 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_TermThis function constructs and returns owner term filter for elasticsearch query.
| Type | Description |
|---|---|
| \Elastica_Filter_Term |

getRecordsFromDocs(
$docs
)
:
arrayGiven 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
)
:
ArrayThis 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_TermThis 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
)
:
voidEither 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
)
:
voidThis indexes one single bean to Elastic Search engine
| Name | Type | Description |
|---|---|---|
| $bean | \SugarBean |

isModuleFtsEnabled(
$module
)
:
boolDetermine if a module is FTS enabled.
Inherited from: \SugarSearchEngineAbstractBase::isModuleFtsEnabled()| Name | Type | Description |
|---|---|---|
| $module |
| Type | Description |
|---|---|
| bool |

isSearchEngineDown(
)
:
BooleanThis function checks config to see if search engine is down.
Inherited from: \SugarSearchEngineAbstractBase::isSearchEngineDown()| Type | Description |
|---|---|
| Boolean |

loader(
$className
)
:
mixedThis function loads the desired file/class from Elastic directory.
| Name | Type | Description |
|---|---|---|
| $className |
| Type | Description |
|---|---|
| mixed |

markSearchEngineStatus(
Boolean $isDown
=
true
)
:
voidThis 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 |