Skip to content

Commit

Permalink
Remove fielddata fields and fix Fix Set fielddata=true (#1209)
Browse files Browse the repository at this point in the history
* fielddata_fields has been deprecated in ES5, use parameter docvalue_fields instead (#1184)

* Fix Set fielddata=true on [answer] (#1184)
  • Loading branch information
p365labs authored and ruflin committed Nov 9, 2016
1 parent 16764ce commit f1d9c0e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ All notable changes to this project will be documented in this file based on the
- implemented painless as default scripting language in tests
- removed search_type=count is removed in Elasticsearch 5.0
- removed logging.yml as now ES 5.0 uses log4j2.properties (leaving defaults)
- removed fielddata_fields has been deprecated in ES5, use parameter docvalue_fields instead
- Fielddata is disabled on text fields by default in this ES release, enabled on tests Elastica\Test\Query\InnerHitsTest.php::testInnerHitsWithSort and Elastica\Test\Query\InnerHitsTest.php::testInnerHitsWithFieldData

### Bugfixes

Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Aggregation/TopHits.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,6 @@ public function setHighlight(array $highlightArgs)
*/
public function setFieldDataFields(array $fields)
{
return $this->setParam('fielddata_fields', $fields);
return $this->setParam('docvalue_fields', $fields);
}
}
2 changes: 1 addition & 1 deletion lib/Elastica/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function setStoredFields(array $fields)
*/
public function setFieldDataFields(array $fieldDataFields)
{
return $this->setParam('fielddata_fields', $fieldDataFields);
return $this->setParam('docvalue_fields', $fieldDataFields);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Query/InnerHits.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ public function setHighlight(array $highlightArgs)
*/
public function setFieldDataFields(array $fields)
{
return $this->setParam('fielddata_fields', $fields);
return $this->setParam('docvalue_fields', $fields);
}
}
2 changes: 1 addition & 1 deletion test/lib/Elastica/Test/Aggregation/TopHitsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function testSetFieldDataFields()
$fields = ['title', 'tags'];
$agg = new TopHits('agg_name');
$returnValue = $agg->setFieldDataFields($fields);
$this->assertEquals($fields, $agg->getParam('fielddata_fields'));
$this->assertEquals($fields, $agg->getParam('docvalue_fields'));
$this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
}

Expand Down
8 changes: 3 additions & 5 deletions test/lib/Elastica/Test/Query/InnerHitsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function _getIndexForNestedTest()
'users' => [
'type' => 'nested',
'properties' => [
'name' => ['type' => 'string'],
'name' => ['type' => 'string', 'fielddata' => 'true'],
],
],
'title' => ['type' => 'string'],
Expand Down Expand Up @@ -110,7 +110,7 @@ protected function _getIndexForParentChildrenTest()

// Set mapping
$mappingResponse->setProperties([
'answer' => ['type' => 'string'],
'answer' => ['type' => 'string', 'fielddata' => 'true'],
'last_activity_date' => ['type' => 'date'],
]);
$mappingResponse->send();
Expand Down Expand Up @@ -262,7 +262,7 @@ public function testSetFieldDataFields()
$fields = ['title', 'tags'];
$innerHits = new InnerHits();
$returnValue = $innerHits->setFieldDataFields($fields);
$this->assertEquals($fields, $innerHits->getParam('fielddata_fields'));
$this->assertEquals($fields, $innerHits->getParam('docvalue_fields'));
$this->assertInstanceOf('Elastica\Query\InnerHits', $returnValue);
}

Expand Down Expand Up @@ -406,7 +406,6 @@ public function testInnerHitsWithSort()
$innerHits = new InnerHits();
$innerHits->setSort(['answer' => 'asc']);

$this->_markSkipped50('Set fielddata=true on [answer] in order to load fielddata in memory');
$results = $this->getParentChildQuery($queryString, $innerHits);
$firstResult = current($results->getResults());

Expand Down Expand Up @@ -513,7 +512,6 @@ public function testInnerHitsWithFieldData()
$queryString = new SimpleQueryString('question simon', ['title', 'users.name']);
$innerHits = new InnerHits();

$this->_markSkipped50('Set fielddata=true on [answer] in order to load fielddata in memory');
$innerHits->setFieldDataFields(['users.name']);

$results = $this->getNestedQuery($queryString, $innerHits);
Expand Down

0 comments on commit f1d9c0e

Please sign in to comment.