Merge tag 'v2.1.3'

Conflicts:
	DependencyInjection/Configuration.php
	README.md
This commit is contained in:
Tim Nagel 2013-10-30 09:06:48 +11:00
commit 85c4dc92f9
4 changed files with 81 additions and 5 deletions

View file

@ -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'])) {

View file

@ -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

View file

@ -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" }
```

View 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());
}
}