parisholley / wordpress-fantastic-elasticsearch

Improve wordpress search performance/accuracy and enable faceted search by leveraging an ElasticSearch server.
MIT License
162 stars 64 forks source link

Add filter in _map to manipulate full mapping #67

Closed stonor closed 10 years ago

stonor commented 10 years ago

It could be great with a indexer filter that allows to manipulate the full mapping object before it is sent to Elasticsearch (in the _map method).

My usecase is that I need to add the _boost field to the mapping object and _boost lives outside the properties.

stonor commented 10 years ago

In case anyone else needs this, I ended up adding my code directly in the _map method while hoping for a filter:

foreach(Config::types() as $type){ $type = $index->getType($type);

  $mapping = new \Elastica\Type\Mapping($type);
  $boost = array (
    'name' => 'search_weight',
    'null_value' => 1.0
  );

  $mapping->setParam('_boost', $boost);
  $mapping->send();
}
parisholley commented 10 years ago

this has been addressed in the 2.2 branch