Merge tag 'v2.1.3'
Conflicts: DependencyInjection/Configuration.php README.md
This commit is contained in:
commit
85c4dc92f9
|
@ -339,6 +339,14 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('index_options')->end()
|
||||
->scalarNode('ignore_above')->end()
|
||||
->scalarNode('position_offset_gap')->end()
|
||||
->arrayNode('_parent')
|
||||
->treatNullLike(array())
|
||||
->children()
|
||||
->scalarNode('type')->end()
|
||||
->scalarNode('identifier')->defaultValue('id')->end()
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('format')->end();
|
||||
;
|
||||
|
||||
if (isset($nestings['fields'])) {
|
||||
|
|
|
@ -45,6 +45,22 @@ class TransformedFinder implements PaginatedFinderInterface
|
|||
return $this->transformer->hybridTransform($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find documents similar to one with passed id.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param array $params
|
||||
* @param array $query
|
||||
* @return array of model objects
|
||||
**/
|
||||
public function moreLikeThis($id, $params = array(), $query = array())
|
||||
{
|
||||
$doc = new Document($id);
|
||||
$results = $this->searchable->moreLikeThis($doc, $params, $query)->getResults();
|
||||
|
||||
return $this->transformer->transform($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param null|int $limit
|
||||
|
|
28
README.md
28
README.md
|
@ -102,9 +102,9 @@ Here we created a "website" index, that uses our "default" client.
|
|||
|
||||
Our index is now available as a service: `fos_elastica.index.website`. It is an instance of `\Elastica\Index`.
|
||||
|
||||
If you need to have different index name from the service name, for example,
|
||||
in order to have different indexes for different environments then you can
|
||||
use the ```index_name``` key to change the index name. The service name will
|
||||
If you need to have different index name from the service name, for example,
|
||||
in order to have different indexes for different environments then you can
|
||||
use the ```index_name``` key to change the index name. The service name will
|
||||
remain the same across the environments:
|
||||
|
||||
fos_elastica:
|
||||
|
@ -114,8 +114,8 @@ remain the same across the environments:
|
|||
website:
|
||||
client: default
|
||||
index_name: website_qa
|
||||
|
||||
The service id will be `fos_elastica.index.website` but the underlying index name is website_qa.
|
||||
|
||||
The service id will be `fos_elastica.index.website` but the underlying index name is website_qa.
|
||||
|
||||
#### Declare a type
|
||||
|
||||
|
@ -796,3 +796,21 @@ $term = new \Elastica\Filter\Term(array('active' => true));
|
|||
$filteredQuery = new \Elastica\Query\Filtered($query, $term);
|
||||
$results = $this->container->get('fos_elastica.finder.index.type')->find($filteredQuery);
|
||||
```
|
||||
|
||||
### Date format example
|
||||
|
||||
If you want to specify a [date format](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html):
|
||||
|
||||
```yaml
|
||||
fos_elastica:
|
||||
clients:
|
||||
default: { host: localhost, port: 9200 }
|
||||
indexes:
|
||||
site:
|
||||
types:
|
||||
user:
|
||||
mappings:
|
||||
username: { type: string }
|
||||
lastlogin: { type: date, format: basic_date_time }
|
||||
birthday: { type: date, format: "yyyy-MM-dd" }
|
||||
```
|
||||
|
|
34
Tests/DependencyInjection/ConfigurationTest.php
Normal file
34
Tests/DependencyInjection/ConfigurationTest.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace FOS\ElasticaBundle\Tests\Resetter\DependencyInjection;
|
||||
|
||||
use FOS\ElasticaBundle\DependencyInjection\Configuration;
|
||||
|
||||
/**
|
||||
* ConfigurationTest
|
||||
*/
|
||||
class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->configuration = new Configuration(array());
|
||||
}
|
||||
|
||||
public function testEmptyConfigContainsFormatMappingOptionNode()
|
||||
{
|
||||
$tree = $this->configuration->getConfigTree();
|
||||
$children = $tree->getChildren();
|
||||
$children = $children['indexes']->getPrototype()->getChildren();
|
||||
$typeNodes = $children['types']->getPrototype()->getChildren();
|
||||
$mappings = $typeNodes['mappings']->getPrototype()->getChildren();
|
||||
|
||||
$this->assertArrayHasKey('format', $mappings);
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Definition\ScalarNode', $mappings['format']);
|
||||
$this->assertNull($mappings['format']->getDefaultValue());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue