include/SugarSearchEngine/Elastic/Elastica/Index.php
Elastica index object
Handles reads, deletes and configurations of an index
- Author
- Nicolas Ruflin
- Category
- Xodoa
- Package
- Elastica
\Elastica_Index
Elastica index object
Handles reads, deletes and configurations of an index
- Parent(s)
- \Elastica_Searchable
- Author
- Nicolas Ruflin
- Category
- Xodoa
Properties
Methods

__construct(
\Elastica_Client $client, string $name
)
:
voidCreates a new index object
All the communication to and from an index goes of this object
| Name | Type | Description |
|---|---|---|
| $client | \Elastica_Client | Client object |
| $name | string | Index name |

addAlias(
string $name, bool $replace
=
false
)
:
\Elastica_ResponseAdds an alias to the current index
| Name | Type | Description |
|---|---|---|
| $name | string | Alias name |
| $replace | bool | OPTIONAL If set, an existing alias will be replaced |
| Type | Description |
|---|---|
| \Elastica_Response | Response |

addDocuments(
array $docs
)
:
voidUses _bulk to send documents to the server
| Name | Type | Description |
|---|---|---|
| $docs | array | Array of Elastica_Document |

clearCache(
)
:
\Elastica_ResponseClears the cache of an index
| Type | Description |
|---|---|
| \Elastica_Response | Reponse object |

close(
)
:
\Elastica_ResponseCloses the index
| Type | Description |
|---|---|
| \Elastica_Response | Response object |

count(
string | array | \Elastica_Query $query
=
''
)
:
intCounts results of query
| Name | Type | Description |
|---|---|---|
| $query | string | array | \Elastica_Query | Array with all query data inside or a Elastica_Query object |
| Type | Description |
|---|---|
| int | number of documents matching the query |

create(
array $args
=
array(), bool $recreate
=
false
)
:
arrayCreates a new index with the given arguments
| Name | Type | Description |
|---|---|---|
| $args | array | OPTIONAL Arguments to use |
| $recreate | bool | OPTIONAL Deletes index first if already exists (default = false) |
| Type | Description |
|---|---|
| array | Server response |

delete(
)
:
\Elastica_ResponseDeletes the index
| Type | Description |
|---|---|
| \Elastica_Response | Response object |

flush(
)
:
\Elastica_ResponseFlushs the index to storage
| Type | Description |
|---|---|
| \Elastica_Response | Reponse object |

getClient(
)
:
\Elastica_ClientReturns index client
| Type | Description |
|---|---|
| \Elastica_Client | Index client object |

getSettings(
)
:
\Elastica_Index_SettingsReturns the index settings object
| Type | Description |
|---|---|
| \Elastica_Index_Settings | Settings object |

getStatus(
)
:
\Elastica_Index_StatusReturns the current status of the index
| Type | Description |
|---|---|
| \Elastica_Index_Status | Index status |

getType(
string $type
)
:
\Elastica_TypeReturns a type object for the current index with the given name
| Name | Type | Description |
|---|---|---|
| $type | string | Type name |
| Type | Description |
|---|---|
| \Elastica_Type | Type object |

open(
)
:
\Elastica_ResponseOpens an index
| Type | Description |
|---|---|
| \Elastica_Response | Response object |

optimize(
array $args
=
array()
)
:
arrayOptimizes search index
Detailed arguments can be found here in the link
| Name | Type | Description |
|---|---|---|
| $args | array | OPTIONAL Additional arguments |
| Type | Description |
|---|---|
| array | Server response |

refresh(
)
:
\Elastica_ResponseRefreshs the index
| Type | Description |
|---|---|
| \Elastica_Response | Response object |

removeAlias(
string $name
)
:
\Elastica_ResponseRemoves an alias pointing to the current index
| Name | Type | Description |
|---|---|---|
| $name | string | Alias name |
| Type | Description |
|---|---|
| \Elastica_Response | Response |

request(
string $path, string $method, array $data
=
array()
)
:
\Elastica_ResponseMakes calls to the elasticsearch server based on this index
| Name | Type | Description |
|---|---|---|
| $path | string | Path to call |
| $method | string | Rest method to use (GET, POST, DELETE, PUT) |
| $data | array | OPTIONAL Arguments as array |
| Type | Description |
|---|---|
| \Elastica_Response | Response object |

search(
string | array | \Elastica_Query $query, int $limit
=
0
)
:
\Elastica_ResultSetSearchs in this index
| Name | Type | Description |
|---|---|---|
| $query | string | array | \Elastica_Query | Array with all query data inside or a Elastica_Query object |
| $limit | int | OPTIONAL |
| Type | Description |
|---|---|
| \Elastica_ResultSet | ResultSet with all results inside |

setSettings(
array $data
)
:
\Elastica_ResponseCan be used to change settings during runtime. One example is to use if for bulk updating {@link http://www.elasticsearch.org/blog/2011/03/23/update-settings.html}
| Name | Type | Description |
|---|---|---|
| $data | array | Data array |
| Type | Description |
|---|---|
| \Elastica_Response | Response object |