Merge branch '3.0.x'
This commit is contained in:
commit
7f28be3c4e
|
@ -12,6 +12,10 @@ https://github.com/FriendsOfSymfony/FOSElasticaBundle/compare/v3.0.0...v3.0.1
|
||||||
To generate a changelog summary since the last version, run
|
To generate a changelog summary since the last version, run
|
||||||
`git log --no-merges --oneline v3.0.0...3.0.x`
|
`git log --no-merges --oneline v3.0.0...3.0.x`
|
||||||
|
|
||||||
|
* 3.0.8 (Unreleased)
|
||||||
|
|
||||||
|
* Fixed handling of empty indexes #760
|
||||||
|
|
||||||
* 3.0.7 (2015-01-21)
|
* 3.0.7 (2015-01-21)
|
||||||
|
|
||||||
* Fixed the indexing of parent/child relations, broken since 3.0 #774
|
* Fixed the indexing of parent/child relations, broken since 3.0 #774
|
||||||
|
|
|
@ -40,16 +40,7 @@ class ContainerSource implements SourceInterface
|
||||||
{
|
{
|
||||||
$indexes = array();
|
$indexes = array();
|
||||||
foreach ($this->configArray as $config) {
|
foreach ($this->configArray as $config) {
|
||||||
$types = array();
|
$types = $this->getTypes($config);
|
||||||
foreach ($config['types'] as $typeConfig) {
|
|
||||||
$types[$typeConfig['name']] = new TypeConfig(
|
|
||||||
$typeConfig['name'],
|
|
||||||
$typeConfig['mapping'],
|
|
||||||
$typeConfig['config']
|
|
||||||
);
|
|
||||||
// TODO: handle prototypes..
|
|
||||||
}
|
|
||||||
|
|
||||||
$index = new IndexConfig($config['name'], $types, array(
|
$index = new IndexConfig($config['name'], $types, array(
|
||||||
'elasticSearchName' => $config['elasticsearch_name'],
|
'elasticSearchName' => $config['elasticsearch_name'],
|
||||||
'settings' => $config['settings'],
|
'settings' => $config['settings'],
|
||||||
|
@ -61,4 +52,28 @@ class ContainerSource implements SourceInterface
|
||||||
|
|
||||||
return $indexes;
|
return $indexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds TypeConfig objects for each type.
|
||||||
|
*
|
||||||
|
* @param array $config
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getTypes($config)
|
||||||
|
{
|
||||||
|
$types = array();
|
||||||
|
|
||||||
|
if (isset($config['types'])) {
|
||||||
|
foreach ($config['types'] as $typeConfig) {
|
||||||
|
$types[$typeConfig['name']] = new TypeConfig(
|
||||||
|
$typeConfig['name'],
|
||||||
|
$typeConfig['mapping'],
|
||||||
|
$typeConfig['config']
|
||||||
|
);
|
||||||
|
// TODO: handle prototypes..
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $types;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ index and type for which the service will provide.
|
||||||
# app/config/config.yml
|
# app/config/config.yml
|
||||||
services:
|
services:
|
||||||
acme.search_provider.user:
|
acme.search_provider.user:
|
||||||
class: Acme\UserBundle\Search\UserProvider
|
class: Acme\UserBundle\Provider\UserProvider
|
||||||
arguments:
|
arguments:
|
||||||
- @fos_elastica.index.website.user
|
- @fos_elastica.index.website.user
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -58,25 +58,28 @@ fos_elastica:
|
||||||
clients:
|
clients:
|
||||||
default: { host: localhost, port: 9200 }
|
default: { host: localhost, port: 9200 }
|
||||||
indexes:
|
indexes:
|
||||||
search: ~
|
app: ~
|
||||||
```
|
```
|
||||||
|
|
||||||
In this example, an Elastica index (an instance of `Elastica\Index`) is available as a
|
In this example, an Elastica index (an instance of `Elastica\Index`) is available as a
|
||||||
service with the key `fos_elastica.index.search`.
|
service with the key `fos_elastica.index.app`.
|
||||||
|
|
||||||
If the Elasticsearch index name needs to be different to the service name in your
|
You may want the index `app` to be named something else on ElasticSearch depending on
|
||||||
application, for example, renaming the search index based on different environments.
|
if your application is running in a different env or other conditions that suit your
|
||||||
|
application. To set your customer index to a name that depends on the environment of your
|
||||||
|
Symfony application, use the example below:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
#app/config/config.yml
|
#app/config/config.yml
|
||||||
fos_elastica:
|
fos_elastica:
|
||||||
indexes:
|
indexes:
|
||||||
search:
|
app:
|
||||||
index_name: search_dev
|
index_name: app_%kernel.env%
|
||||||
```
|
```
|
||||||
|
|
||||||
In this case, the service `fos_elastica.index.search` will be using an Elasticsearch
|
In this case, the service `fos_elastica.index.app` will relate to an ElasticSearch index
|
||||||
index of search_dev.
|
that varies depending on your kernel's environment. For example, in dev it will relate to
|
||||||
|
`app_dev`.
|
||||||
|
|
||||||
D: Defining index types
|
D: Defining index types
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@ -91,7 +94,7 @@ will end up being indexed.
|
||||||
```yaml
|
```yaml
|
||||||
fos_elastica:
|
fos_elastica:
|
||||||
indexes:
|
indexes:
|
||||||
search:
|
app:
|
||||||
types:
|
types:
|
||||||
user:
|
user:
|
||||||
mappings:
|
mappings:
|
||||||
|
@ -102,7 +105,7 @@ fos_elastica:
|
||||||
```
|
```
|
||||||
|
|
||||||
Each defined type is made available as a service, and in this case the service key is
|
Each defined type is made available as a service, and in this case the service key is
|
||||||
`fos_elastica.index.search.user` and is an instance of `Elastica\Type`.
|
`fos_elastica.index.app.user` and is an instance of `Elastica\Type`.
|
||||||
|
|
||||||
FOSElasticaBundle requires a provider for each type that will notify when an object
|
FOSElasticaBundle requires a provider for each type that will notify when an object
|
||||||
that maps to a type has been modified. The bundle ships with support for Doctrine and
|
that maps to a type has been modified. The bundle ships with support for Doctrine and
|
||||||
|
|
|
@ -32,11 +32,15 @@ class MappingToElasticaTest extends WebTestCase
|
||||||
$this->assertTrue($mapping['type']['properties']['field1']['store']);
|
$this->assertTrue($mapping['type']['properties']['field1']['store']);
|
||||||
$this->assertArrayNotHasKey('store', $mapping['type']['properties']['field2']);
|
$this->assertArrayNotHasKey('store', $mapping['type']['properties']['field2']);
|
||||||
|
|
||||||
|
$type = $this->getType($client, 'type');
|
||||||
|
$mapping = $type->getMapping();
|
||||||
|
$this->assertEquals('parent', $mapping['type']['_parent']['type']);
|
||||||
|
|
||||||
$parent = $this->getType($client, 'parent');
|
$parent = $this->getType($client, 'parent');
|
||||||
$mapping = $parent->getMapping();
|
$mapping = $parent->getMapping();
|
||||||
|
|
||||||
$this->assertEquals('my_analyzer', $mapping['parent']['index_analyzer']);
|
$this->assertEquals('my_analyzer', $mapping['type']['index_analyzer']);
|
||||||
$this->assertEquals('whitespace', $mapping['parent']['search_analyzer']);
|
$this->assertEquals('whitespace', $mapping['type']['search_analyzer']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testResetType()
|
public function testResetType()
|
||||||
|
|
|
@ -95,3 +95,4 @@ fos_elastica:
|
||||||
identifier: "id"
|
identifier: "id"
|
||||||
null_mappings:
|
null_mappings:
|
||||||
mappings: ~
|
mappings: ~
|
||||||
|
empty_index: ~
|
||||||
|
|
Loading…
Reference in a new issue