WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c31e66c

Browse files
Merge remote-tracking branch 'origin/develop'
2 parents 7e3ca50 + 904a5c3 commit c31e66c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1133
-499
lines changed

Behat/SearchManagerContext.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ public function iSearchFor($query)
193193
->execute();
194194
}
195195

196+
/**
197+
* @When I search for :query with sort :sort and order :order
198+
*/
199+
public function iSearchForWithSort($query, $sort, $order)
200+
{
201+
$this->lastResult = $this->getSearchManager()
202+
->createSearch($query)
203+
->indexes($this->getSearchManager()->getIndexNames())
204+
->addSorting($sort, $order)
205+
->execute();
206+
}
207+
196208
/**
197209
* @Given I search for :query in locale :locale
198210
*/
@@ -280,6 +292,14 @@ public function theResultShouldBeAnArray()
280292
Assert::assertInternalType('array', $this->lastResult);
281293
}
282294

295+
/**
296+
* @Then the result at position :position should be :id
297+
*/
298+
public function theResultAtPositionShouldBe($position, $id)
299+
{
300+
Assert::assertEquals($this->lastResult[$position]->getId(), $id);
301+
}
302+
283303
/**
284304
* Return the search manager using the configured adapter ID.
285305
*/
@@ -290,7 +310,7 @@ protected function getSearchManager()
290310
$this->kernel->getContainer()->get('massive_search.metadata.provider.chain'),
291311
$this->kernel->getContainer()->get('massive_search.object_to_document_converter'),
292312
$this->kernel->getContainer()->get('event_dispatcher'),
293-
$this->kernel->getContainer()->get('massive_search.localization_strategy'),
313+
$this->kernel->getContainer()->get('massive_search.index_name_decorator.default'),
294314
$this->kernel->getContainer()->get('massive_search.metadata.field_evaluator')
295315
);
296316
}

CHANGELOG.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,66 @@
11
CHANGELOG
22
=========
33

4+
* 0.11.0 (2015-12-01)
5+
* BUGFIX #71 Fixed caching of repository method
6+
* BUGFIX #70 Added missing passing of options to PrefixDecorator
7+
* FEATURE #67 Added support for sort/order for elastic search
8+
* FEATURE #68 Introduce decorators for index names and introduce prefixes
9+
* FEATURE #66 Added support for date
10+
* FEATURE #60 Added support for custom type converter
11+
* FEATURE #60 Added support for arrays
12+
413
* 0.10.0 (2015-11-19)
514
* FEATURE #66 [Converter] Added support for date
615
* FEATURE #60 [Converter] Added support for custom type converter
716
* FEATURE #60 [General] Added support for arrays
817

918
* 0.9.0
10-
* FEATURE [Configuration] Index name can now also be created using expression language
11-
* FEATURE [Configuration] Search categories have been removed
19+
* FEATURE Index name can now also be created using expression language
20+
* FEATURE Search categories have been removed
1221

1322
* 0.8.0
14-
* FEATURE [Rebuild] Added reindex directive
15-
* FEATURE [Tests] Removed prophecy bridge
16-
* FEATURE [General] Added Style-CI configuration
23+
* FEATURE Added reindex directive
24+
* FEATURE Removed prophecy bridge
25+
* FEATURE Added Style-CI configuration
1726

1827
* 0.7.0
19-
* BUGFIX [Metadata] Added scalar check
28+
* BUGFIX Added scalar check
2029

2130
* 0.6.0
22-
* BUGFIX [Configuraiton] Undefined index when elastic search is used without
23-
configuration
24-
* BUGFIX [Search] If not localized managed indexes exist then a global search is
25-
performed: https://github.com/massiveart/MassiveSearchBundle/issues/38
26-
* BUGFIX [Metadata] Removed index strategies, replaced with explicit `stored` and
27-
`indexed` and `aggregate` flags (**BC BREAK**).
28-
* BUGFIX [Metadata] Added metadata cache
29-
* BUGFIX [Metadata] Added metadata providers
31+
* BUGFIX Undefined index when elastic search is used without
32+
configuration
33+
* BUGFIX If not localized managed indexes exist then a global search is
34+
performed: https://github.com/massiveart/MassiveSearchBundle/issues/38
35+
* BUGFIX Removed index strategies, replaced with explicit `stored` and
36+
`indexed` and `aggregate` flags (**BC BREAK**).
37+
* BUGFIX Added metadata cache
38+
* BUGFIX Added metadata providers
3039

3140
* 0.5.1
32-
* FEATURE [ZendLucene] Add index strategy 'INDEX_STORED_INDEXED'
41+
* FEATURE Add index strategy 'INDEX_STORED_INDEXED'
3342

3443
* 0.5.0
35-
* FEATURE [TestAdapter] Supports indexes
36-
* FEATURE [Mapping] Expression language
37-
* FEATURE [Persistence] Doctrine ORM event subscriber
38-
* FEATURE [Elastic] Elasticsearch adapter
39-
* FEATURE [Localization] Localization strategy support
40-
* ENHANCEMENT [Config] Renamed `adapter_id` to `adapter` in configuration. See UPGRADE.md
41-
* ENHANCEMENT [Rebuild] Added core support for rebuilding indexes via
44+
* FEATURE Supports indexes
45+
* FEATURE Expression language
46+
* FEATURE Doctrine ORM event subscriber
47+
* FEATURE Elasticsearch adapter
48+
* FEATURE Localization strategy support
49+
* ENHANCEMENT Renamed `adapter_id` to `adapter` in configuration. See UPGRADE.md
50+
* ENHANCEMENT Added core support for rebuilding indexes via
4251
massive:search:index:rebuild command
4352

4453
* 0.4.1
45-
* BUGFIX [TestAdapter] Fixed deindexing
54+
* BUGFIX Fixed deindexing
4655

4756
* 0.4.0
48-
* FEATURE [TestAdapter] Test (memory storage) adapter now uses regex when searching
57+
* FEATURE Test (memory storage) adapter now uses regex when searching
4958

5059
0.3.2
51-
* BUGFIX [ZendSearch] Catch "non-wildcard characters" exception and return 0 results
60+
* BUGFIX Catch "non-wildcard characters" exception and return 0 results
5261

5362
0.3.1
54-
* BUGFIX [ZendSeach] Added workaround to avoid Fatal errors after a test suite run caused by
63+
* BUGFIX Added workaround to avoid Fatal errors after a test suite run caused by
5564
the Lucene\Index `__destruct()` method. You can now configure the adapter to hide Exceptions
5665
from the Index class.
5766

DependencyInjection/Configuration.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ public function getConfigTreeBuilder()
3232
->scalarNode('factory')->defaultValue('massive_search.factory_default')->end()
3333
->end()
3434
->end()
35-
->enumNode('localization_strategy')
36-
->values(['noop', 'index'])
37-
->defaultValue('noop')
38-
->end()
3935
->enumNode('adapter')
4036
->values(['zend_lucene', 'elastic', 'test'])
4137
->defaultValue('zend_lucene')->end()
@@ -64,6 +60,7 @@ public function getConfigTreeBuilder()
6460
->arrayNode('metadata')
6561
->addDefaultsIfNotSet()
6662
->children()
63+
->scalarNode('prefix')->defaultValue('massive')->end()
6764
->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/massive-search')->end()
6865
->booleanNode('debug')->defaultValue('%kernel.debug%')->end()
6966
->end()

DependencyInjection/MassiveSearchExtension.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function load(array $configs, ContainerBuilder $container)
3535

3636
$container->setAlias('massive_search.factory', $config['services']['factory']);
3737

38-
$this->loadLocalization($config, $loader, $container);
3938
$this->loadSearch($config, $loader, $container);
4039
$this->loadMetadata($config['metadata'], $loader, $container);
4140
$this->loadPersistence($config['persistence'], $loader);
@@ -52,23 +51,6 @@ private function loadPersistence($config, Loader\XmlFileLoader $loader)
5251
}
5352
}
5453

55-
private function loadLocalization($config, $loader, $container)
56-
{
57-
$loader->load('localization.xml');
58-
$strategy = $config['localization_strategy'];
59-
60-
switch ($strategy) {
61-
case 'noop':
62-
$strategyId = 'massive_search.localization_strategy.noop';
63-
break;
64-
case 'index':
65-
$strategyId = 'massive_search.localization_strategy.index';
66-
break;
67-
}
68-
69-
$container->setAlias('massive_search.localization_strategy', $strategyId);
70-
}
71-
7254
private function loadSearch($config, $loader, $container)
7355
{
7456
$container->setAlias('massive_search.adapter', 'massive_search.adapter.' . $config['adapter']);
@@ -112,6 +94,7 @@ private function loadMetadata($config, $loader, $container)
11294
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $dir));
11395
}
11496
}
97+
$container->setParameter('massive_search.metadata.prefix', $config['prefix']);
11598
$container->setParameter('massive_search.metadata.cache_dir', $config['cache_dir']);
11699
$container->setParameter('massive_search.metadata.debug', $config['debug']);
117100

Resources/config/adapter_zendlucene.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
<argument>%massive_search.adapter.zend_lucene.basepath%</argument>
1010
<argument>%massive_search.adapter.zend_lucene.hide_index_exception%</argument>
1111
<argument>%massive_search.adapter.zend_lucene.encoding%</argument>
12+
</service>
13+
14+
<service id="massive_search.events.zend_rebuild"
15+
class="Massive\Bundle\SearchBundle\Search\EventListener\ZendRebuildSubscriber">
16+
<argument type="service" id="massive_search.adapter.zend_lucene"/>
17+
<argument type="service" id="massive_search.index_name_decorator.default"/>
1218
<tag name="kernel.event_listener" event="massive_search.index_rebuild"
13-
method="optimizeIndexAfterRebuild"
19+
method="onIndexRebuild"
1420
priority="-999"/>
1521
</service>
1622
</services>

Resources/config/localization.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

Resources/config/search.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,29 @@
3333
<argument type="service" id="massive_search.factory" />
3434
</service>
3535

36+
<!-- Decorators -->
37+
<service id="massive_search.index_name_decorator" class="Massive\Bundle\SearchBundle\Search\Decorator\IndexNameDecorator">
38+
<argument type="service" id="massive_search.metadata.field_evaluator"/>
39+
</service>
40+
41+
<service id="massive_search.localization_decorator" class="Massive\Bundle\SearchBundle\Search\Decorator\LocalizationDecorator">
42+
<argument type="service" id="massive_search.index_name_decorator"/>
43+
</service>
44+
45+
<service id="massive_search.prefix_decorator" class="Massive\Bundle\SearchBundle\Search\Decorator\PrefixDecorator">
46+
<argument type="service" id="massive_search.localization_decorator"/>
47+
<argument>%massive_search.metadata.prefix%</argument>
48+
</service>
49+
50+
<service id="massive_search.index_name_decorator.default" alias="massive_search.prefix_decorator"/>
51+
3652
<!-- Search manager -->
3753
<service id="massive_search.search_manager" class="%massive_search.search_manager.class%">
3854
<argument type="service" id="massive_search.adapter" />
3955
<argument type="service" id="massive_search.metadata.provider.chain" />
4056
<argument type="service" id="massive_search.object_to_document_converter" />
4157
<argument type="service" id="event_dispatcher" />
42-
<argument type="service" id="massive_search.localization_strategy" />
58+
<argument type="service" id="massive_search.index_name_decorator.default" />
4359
<argument type="service" id="massive_search.metadata.field_evaluator" />
4460
</service>
4561

Resources/docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Contents
1313
mapping
1414
searching
1515
search_adapters
16-
localization
16+
index_name_decorators
1717
web_api
1818
extending
1919
commands
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Index name decorators
2+
=====================
3+
4+
The bundle offers the possibility to influence the generated index names using
5+
the `decorator pattern`_. If you want to add your own decorator, you have to
6+
implement the `IndexNameDecoratorInterface`, and register the new decorator in
7+
the `Symfony dependency injection container`_. Consider that you should pass
8+
the current most outer decorator as an argument, so that it can be called in
9+
your decorator.
10+
11+
Afterwards you have to make sure that your new decorator is returned when
12+
getting the service for `massive_search.index_name_decorator.default`, what can
13+
be achieved by using the `alias feature`_ of Symfony.
14+
15+
Available index name decorators
16+
-------------------------------
17+
18+
IndexNameDecorator
19+
~~~~~~~~~~~~~~~~~~
20+
21+
The index name decorator returns the value for the index name from the
22+
:doc:`mapping` files.
23+
24+
LocalizationDecorator
25+
~~~~~~~~~~~~~~~~~~~~~
26+
27+
This decorator adds the locale to the index name, in case the document has a
28+
locale parameter.
29+
30+
PrefixDecorator
31+
~~~~~~~~~~~~~~~
32+
33+
The `PrefixDecorator` is responsible for adding a prefix to the index, so that
34+
the Bundle knows if the given index name is managed by the search bundle. This
35+
prefix can be configured by the `massive_search.metadata.prefix` configuration
36+
setting, which defaults to ``massive``.
37+
38+
.. warning::
39+
40+
Make sure that the other indexes you might have in your system have a name
41+
not starting with the prefix defined by this configuration. Otherwise it
42+
might be possible that the MassiveSearchBundle modifies or deletes these
43+
indexes.
44+
45+
.. _`decorator pattern`: https://en.wikipedia.org/wiki/Decorator_pattern
46+
.. _`Symfony dependency injection container`: http://symfony.com/doc/current/components/dependency_injection/introduction.html#setting-up-the-container-with-configuration-files
47+
.. _`alias feature`: http://symfony.com/doc/current/components/dependency_injection/advanced.html#aliasing
48+

Resources/docs/localization.rst

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)