Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added support for index-time document boosting #150

Merged
merged 1 commit into from

2 participants

@predakanga

In the course of my integration of FOQElasticaBundle, I've often come across the need to boost my documents by a field (using http://www.elasticsearch.org/guide/reference/mapping/boost-field.html).

Originally I simply updated the index mapping after each reset, but this became a maintenance nightmare, so I wanted to provide direct support to the bundle, modeled after #85

@richardmiller richardmiller merged commit b376f2c into FriendsOfSymfony:master
@richardmiller
Collaborator

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
19 DependencyInjection/Configuration.php
@@ -214,6 +214,7 @@ protected function getTypesNode()
->end()
->append($this->getMappingsNode())
->append($this->getSourceNode())
+ ->append($this->getBoostNode())
->end()
;
@@ -295,4 +296,22 @@ protected function getSourceNode()
return $node;
}
+
+ /**
+ * Returns the array node used for "_boost".
+ */
+ protected function getBoostNode()
+ {
+ $builder = new TreeBuilder();
+ $node = $builder->root('_boost');
+
+ $node
+ ->children()
+ ->scalarNode('name')->end()
+ ->scalarNode('null_value')->end()
+ ->end()
+ ;
+
+ return $node;
+ }
}
View
3  DependencyInjection/FOQElasticaExtension.php
@@ -170,6 +170,9 @@ protected function loadTypes(array $types, ContainerBuilder $container, $indexNa
if (isset($type['_source'])) {
$this->indexConfigs[$indexName]['config']['mappings'][$name]['_source'] = $type['_source'];
}
+ if (isset($type['_boost'])) {
+ $this->indexConfigs[$indexName]['config']['mappings'][$name]['_boost'] = $type['_boost'];
+ }
if (isset($type['mappings'])) {
$this->indexConfigs[$indexName]['config']['mappings'][$name]['properties'] = $type['mappings'];
$typeName = sprintf('%s/%s', $indexName, $name);
Something went wrong with that request. Please try again.