PHP Trait Elasticquent\ElasticquentTrait

Functionality extensions for Elequent that makes working with Elasticsearch easier.
Inheritance: use trait elasticquent\ElasticquentClientTrait
Afficher le fichier Open project: elasticquent/elasticquent

Protected Properties

Свойство Type Description
$documentScore null | integer Hit score when using data from Elasticsearch results.
$documentVersion null | integer Elasticsearch document version.
$isDocument boolean Set to true when our model is populated by a
$usesTimestampsInIndex boolean Uses Timestamps In Index

Méthodes publiques

Méthode Description
addAllToIndex ( ) : array Index Documents
addToIndex ( ) : array Add to Search Index
complexSearch ( $params ) : elasticquent\ElasticquentResultCollection Perform a "complex" or custom search.
createIndex ( integer $shards = null, integer $replicas = null ) : array Create Index
deleteIndex ( ) : array Delete Index
deleteMapping ( ) : array Delete Mapping
documentScore ( ) : null | float Get Document Score
documentVersion ( ) : null | integer Document Version
dontUseTimestampsInIndex ( ) Don't Use Timestamps In Index.
getBasicEsParams ( boolean $getIdIfPossible = true, boolean $getSourceIfPossible = false, boolean $getTimestampIfPossible = false, integer $limit = null, integer $offset = null ) : array Get Basic Elasticsearch Params
getIndexDocumentData ( ) : array Get Index Document Data
getIndexSettings ( ) : array Get Index Settings
getIndexedDocument ( ) : array Get Search Document
getMapping ( ) : void Get Mapping
getMappingProperties ( ) : array Get Mapping Properties
getTypeName ( ) : string Get Type Name
hydrateElasticquentResult ( array $items, array $meta = null ) : Elasticquent\ElasticquentResultCollection Create a elacticquent result collection of models from plain arrays.
hydrateElasticsearchResult ( array $result ) : Elasticquent\ElasticquentResultCollection Create a elacticquent result collection of models from plain elasticsearch result.
hydrateRecursive ( Model $model, array $items, Illuminate\Database\Eloquent\Relations\Relation $parentRelation = null ) : Illuminate\Database\Eloquent\Collection Create a collection of models from plain arrays recursive.
isDocument ( ) : boolean Is Elasticsearch Document
loadPivotAttribute ( Model $model, Illuminate\Database\Eloquent\Relations\Relation $parentRelation = null ) Get the pivot attribute from a model.
loadRelationsAttributesRecursive ( Model $model ) Get the relations attributes from a model.
mappingExists ( ) : boolean Mapping Exists
newCollection ( array $models = [] ) : ElasticquentCollection New Collection
newElasticquentResultCollection ( array $models = [], array $meta = null ) : Elasticquent\ElasticquentResultCollection Create a new Elasticquent Result Collection instance.
newFromBuilderRecursive ( Model $model, array $attributes = [], Illuminate\Database\Eloquent\Relations\Relation $parentRelation = null ) : static Create a new model instance that is existing recursive.
newFromHitBuilder ( array $hit = [] ) : static New From Hit Builder
putMapping ( boolean $ignoreConflicts = false ) : array Put Mapping.
rebuildMapping ( ) : array Rebuild Mapping
reindex ( ) : array Re-Index All Content
removeFromIndex ( ) : array Remove From Search Index
search ( string $term = '' ) : elasticquent\ElasticquentResultCollection Search
searchByQuery ( array $query = null, array $aggregations = null, array $sourceFields = null, integer $limit = null, integer $offset = null, array $sort = null ) : elasticquent\ElasticquentResultCollection Search By Query
setMappingProperties ( array $mapping = null ) Set Mapping Properties
typeExists ( ) : boolean Type Exists.
updateIndex ( ) : array Partial Update to Indexed Document
useTimestampsInIndex ( $shouldUse = true ) Use Timestamps In Index.
usesTimestampsInIndex ( ) Uses Timestamps In Index.

Private Methods

Méthode Description
buildFieldsParameter ( boolean $getSourceIfPossible, boolean $getTimestampIfPossible ) : array Build the 'fields' parameter depending on given options.
isMultiLevelArray ( array $array ) : boolean Check if an array is multi-level array like [[id], [id], [id]].

Method Details

addAllToIndex() public static méthode

Index all documents in an Eloquent model.
public static addAllToIndex ( ) : array
Résultat array

addToIndex() public méthode

Add to Search Index
public addToIndex ( ) : array
Résultat array

complexSearch() public static méthode

Using this method, a custom query can be sent to Elasticsearch.
public static complexSearch ( $params ) : elasticquent\ElasticquentResultCollection
$params parameters to be passed directly to Elasticsearch
Résultat elasticquent\ElasticquentResultCollection

createIndex() public static méthode

Create Index
public static createIndex ( integer $shards = null, integer $replicas = null ) : array
$shards integer
$replicas integer
Résultat array

deleteIndex() public static méthode

Delete Index
public static deleteIndex ( ) : array
Résultat array

deleteMapping() public static méthode

Delete Mapping
public static deleteMapping ( ) : array
Résultat array

documentScore() public méthode

Get Document Score
public documentScore ( ) : null | float
Résultat null | float

documentVersion() public méthode

Document Version
public documentVersion ( ) : null | integer
Résultat null | integer

dontUseTimestampsInIndex() public méthode

Don't Use Timestamps In Index.
Deprecation:

getBasicEsParams() public méthode

Most Elasticsearch API calls need the index and type passed in a parameter array.
public getBasicEsParams ( boolean $getIdIfPossible = true, boolean $getSourceIfPossible = false, boolean $getTimestampIfPossible = false, integer $limit = null, integer $offset = null ) : array
$getIdIfPossible boolean
$getSourceIfPossible boolean
$getTimestampIfPossible boolean
$limit integer
$offset integer
Résultat array

getIndexDocumentData() public méthode

Get the data that Elasticsearch will index for this particular document.
public getIndexDocumentData ( ) : array
Résultat array

getIndexSettings() public méthode

Get Index Settings
public getIndexSettings ( ) : array
Résultat array

getIndexedDocument() public méthode

Retrieve an ElasticSearch document for this entity.
public getIndexedDocument ( ) : array
Résultat array

getMapping() public static méthode

Get Mapping
public static getMapping ( ) : void
Résultat void

getMappingProperties() public méthode

Get Mapping Properties
public getMappingProperties ( ) : array
Résultat array

getTypeName() public méthode

Get Type Name
public getTypeName ( ) : string
Résultat string

hydrateElasticquentResult() public static méthode

Create a elacticquent result collection of models from plain arrays.
public static hydrateElasticquentResult ( array $items, array $meta = null ) : Elasticquent\ElasticquentResultCollection
$items array
$meta array
Résultat Elasticquent\ElasticquentResultCollection

hydrateElasticsearchResult() public static méthode

Create a elacticquent result collection of models from plain elasticsearch result.
public static hydrateElasticsearchResult ( array $result ) : Elasticquent\ElasticquentResultCollection
$result array
Résultat Elasticquent\ElasticquentResultCollection

hydrateRecursive() public static méthode

Create a collection of models from plain arrays recursive.
public static hydrateRecursive ( Model $model, array $items, Illuminate\Database\Eloquent\Relations\Relation $parentRelation = null ) : Illuminate\Database\Eloquent\Collection
$model Illuminate\Database\Eloquent\Model
$items array
$parentRelation Illuminate\Database\Eloquent\Relations\Relation
Résultat Illuminate\Database\Eloquent\Collection

isDocument() public méthode

Is the data in this module sourced from an Elasticsearch document source?
public isDocument ( ) : boolean
Résultat boolean

loadPivotAttribute() public static méthode

Get the pivot attribute from a model.
public static loadPivotAttribute ( Model $model, Illuminate\Database\Eloquent\Relations\Relation $parentRelation = null )
$model Illuminate\Database\Eloquent\Model
$parentRelation Illuminate\Database\Eloquent\Relations\Relation

loadRelationsAttributesRecursive() public static méthode

Get the relations attributes from a model.
public static loadRelationsAttributesRecursive ( Model $model )
$model Illuminate\Database\Eloquent\Model

mappingExists() public static méthode

Mapping Exists
public static mappingExists ( ) : boolean
Résultat boolean

newCollection() public méthode

New Collection
public newCollection ( array $models = [] ) : ElasticquentCollection
$models array
Résultat ElasticquentCollection

newElasticquentResultCollection() public méthode

Create a new Elasticquent Result Collection instance.
public newElasticquentResultCollection ( array $models = [], array $meta = null ) : Elasticquent\ElasticquentResultCollection
$models array
$meta array
Résultat Elasticquent\ElasticquentResultCollection

newFromBuilderRecursive() public static méthode

Create a new model instance that is existing recursive.
public static newFromBuilderRecursive ( Model $model, array $attributes = [], Illuminate\Database\Eloquent\Relations\Relation $parentRelation = null ) : static
$model Illuminate\Database\Eloquent\Model
$attributes array
$parentRelation Illuminate\Database\Eloquent\Relations\Relation
Résultat static

newFromHitBuilder() public méthode

Variation on newFromBuilder. Instead, takes
public newFromHitBuilder ( array $hit = [] ) : static
$hit array
Résultat static

putMapping() public static méthode

Put Mapping.
public static putMapping ( boolean $ignoreConflicts = false ) : array
$ignoreConflicts boolean
Résultat array

rebuildMapping() public static méthode

This will delete and then re-add the mapping for this model.
public static rebuildMapping ( ) : array
Résultat array

reindex() public static méthode

Re-Index All Content
public static reindex ( ) : array
Résultat array

removeFromIndex() public méthode

Remove From Search Index
public removeFromIndex ( ) : array
Résultat array

searchByQuery() public static méthode

Search with a query array
public static searchByQuery ( array $query = null, array $aggregations = null, array $sourceFields = null, integer $limit = null, integer $offset = null, array $sort = null ) : elasticquent\ElasticquentResultCollection
$query array
$aggregations array
$sourceFields array
$limit integer
$offset integer
$sort array
Résultat elasticquent\ElasticquentResultCollection

setMappingProperties() public méthode

Set Mapping Properties
public setMappingProperties ( array $mapping = null )
$mapping array

typeExists() public static méthode

Does this type exist?
public static typeExists ( ) : boolean
Résultat boolean

updateIndex() public méthode

Partial Update to Indexed Document
public updateIndex ( ) : array
Résultat array

useTimestampsInIndex() public méthode

Use Timestamps In Index.
public useTimestampsInIndex ( $shouldUse = true )

usesTimestampsInIndex() public méthode

Uses Timestamps In Index.

Property Details

$documentScore protected_oe property

Hit score when using data from Elasticsearch results.
protected null|int $documentScore
Résultat null | integer

$documentVersion protected_oe property

Elasticsearch document version.
protected null|int $documentVersion
Résultat null | integer

$isDocument protected_oe property

Set to true when our model is populated by a
protected bool $isDocument
Résultat boolean

$usesTimestampsInIndex protected_oe property

Uses Timestamps In Index
protected bool $usesTimestampsInIndex
Résultat boolean