Skip to content

Commit

Permalink
update tests : use text or keyword instead of string and use boolean …
Browse files Browse the repository at this point in the history
…for store instaed yes/no (#1184) (#1218)
  • Loading branch information
p365labs authored and ruflin committed Nov 17, 2016
1 parent c72a75b commit c44ec85
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 43 deletions.
2 changes: 1 addition & 1 deletion test/lib/Elastica/Test/Aggregation/NestedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function _getIndexForTest()
'resellers' => [
'type' => 'nested',
'properties' => [
'name' => ['type' => 'string'],
'name' => ['type' => 'text'],
'price' => ['type' => 'double'],
],
],
Expand Down
2 changes: 1 addition & 1 deletion test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function _getIndexForTest()
'type' => 'nested',
'properties' => [
'name' => ['type' => 'keyword'],
'body' => ['type' => 'string'],
'body' => ['type' => 'text'],
],
],
'tags' => ['type' => 'keyword'],
Expand Down
20 changes: 10 additions & 10 deletions test/lib/Elastica/Test/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function testMapping()

$type = $index->getType('test');

$mapping = ['id' => ['type' => 'integer', 'store' => true], 'email' => ['type' => 'string', 'store' => 'no'],
'username' => ['type' => 'string', 'store' => 'no'], 'test' => ['type' => 'integer', 'store' => 'no'], ];
$mapping = ['id' => ['type' => 'integer', 'store' => true], 'email' => ['type' => 'text'],
'username' => ['type' => 'text'], 'test' => ['type' => 'integer'], ];
$type->setMapping($mapping);

$type->addDocument($doc);
Expand Down Expand Up @@ -56,7 +56,7 @@ public function testGetMappingAlias()

$type = new Type($index, 'test');
$mapping = new Mapping($type, [
'id' => ['type' => 'integer', 'store' => 'yes'],
'id' => ['type' => 'integer', 'store' => 'true'],
]);
$type->setMapping($mapping);

Expand Down Expand Up @@ -120,7 +120,7 @@ public function testParent()
*/
public function testAddPdfFile()
{
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => false]];
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'text']];

$indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]];

Expand Down Expand Up @@ -161,7 +161,7 @@ public function testAddPdfFile()
*/
public function testAddPdfFileContent()
{
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => false]];
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'text']];

$indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]];

Expand Down Expand Up @@ -202,7 +202,7 @@ public function testAddPdfFileContent()
*/
public function testAddWordxFile()
{
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => 'no']];
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'text']];

$indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]];

Expand Down Expand Up @@ -242,8 +242,8 @@ public function testAddWordxFile()
*/
public function testExcludeFileSource()
{
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => true],
'title' => ['type' => 'string', 'store' => true], ];
$indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'text', 'store' => true],
'title' => ['type' => 'text', 'store' => true], ];

$indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]];

Expand Down Expand Up @@ -692,8 +692,8 @@ public function testIndexGetMapping()
$index = $this->_createIndex();
$type = $index->getType('test');

$mapping = ['id' => ['type' => 'integer', 'store' => true], 'email' => ['type' => 'string', 'store' => false],
'username' => ['type' => 'string', 'store' => false], 'test' => ['type' => 'integer', 'store' => false], ];
$mapping = ['id' => ['type' => 'integer', 'store' => true], 'email' => ['type' => 'text'],
'username' => ['type' => 'text'], 'test' => ['type' => 'integer'], ];

$type->setMapping($mapping);
$index->refresh();
Expand Down
2 changes: 1 addition & 1 deletion test/lib/Elastica/Test/Query/BoostingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function _getTestIndex()
$index = $this->_createIndex();
$type = $index->getType('test');
$type->setMapping([
'name' => ['type' => 'string', 'index' => 'analyzed'],
'name' => ['type' => 'text', 'index' => 'analyzed'],
'price' => ['type' => 'float'],
]);
$docs = [];
Expand Down
2 changes: 1 addition & 1 deletion test/lib/Elastica/Test/Query/FunctionScoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function _getIndexForTest()
$type = $index->getType('test');

$type->setMapping([
'name' => ['type' => 'string', 'index' => 'not_analyzed'],
'name' => ['type' => 'text', 'index' => 'not_analyzed'],
'location' => ['type' => 'geo_point'],
'price' => ['type' => 'float'],
'popularity' => ['type' => 'integer'],
Expand Down
8 changes: 4 additions & 4 deletions test/lib/Elastica/Test/Query/InnerHitsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ protected function _getIndexForNestedTest()
'users' => [
'type' => 'nested',
'properties' => [
'name' => ['type' => 'string', 'fielddata' => 'true'],
'name' => ['type' => 'text', 'fielddata' => 'true'],
],
],
'title' => ['type' => 'string'],
'title' => ['type' => 'text'],
'last_activity_date' => ['type' => 'date'],
]);

Expand Down Expand Up @@ -99,7 +99,7 @@ protected function _getIndexForParentChildrenTest()

// Set mapping
$mappingQuestion->setProperties([
'title' => ['type' => 'string'],
'title' => ['type' => 'text'],
'last_activity_date' => ['type' => 'date'],
]);

Expand All @@ -110,7 +110,7 @@ protected function _getIndexForParentChildrenTest()

// Set mapping
$mappingResponse->setProperties([
'answer' => ['type' => 'string', 'fielddata' => 'true'],
'answer' => ['type' => 'text', 'fielddata' => 'true'],
'last_activity_date' => ['type' => 'date'],
]);
$mappingResponse->send();
Expand Down
4 changes: 2 additions & 2 deletions test/lib/Elastica/Test/Query/MoreLikeThisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function testSearch()

$type = new Type($index, 'helloworldmlt');
$mapping = new Mapping($type, [
'email' => ['store' => 'yes', 'type' => 'string', 'index' => 'analyzed'],
'content' => ['store' => 'yes', 'type' => 'string', 'index' => 'analyzed'],
'email' => ['store' => 'true', 'type' => 'text', 'index' => 'analyzed'],
'content' => ['store' => 'true', 'type' => 'text', 'index' => 'analyzed'],
]);

$mapping->setSource(['enabled' => false]);
Expand Down
6 changes: 3 additions & 3 deletions test/lib/Elastica/Test/Query/MultiMatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ private function _generateIndex()
$type = $index->getType('test');

$mapping = new Mapping($type, [
'name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'],
'last_name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'],
'full_name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'],
'name' => ['type' => 'text', 'analyzer' => 'noStops'],
'last_name' => ['type' => 'text', 'analyzer' => 'noStops'],
'full_name' => ['type' => 'text', 'analyzer' => 'noStops'],
]);

$type->setMapping($mapping);
Expand Down
2 changes: 1 addition & 1 deletion test/lib/Elastica/Test/Query/WildcardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testSearchWithAnalyzer()
$type = $index->getType('test');

$mapping = new Mapping($type, [
'name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'lw'],
'name' => ['type' => 'text', 'analyzer' => 'lw'],
]
);
$type->setMapping($mapping);
Expand Down
4 changes: 2 additions & 2 deletions test/lib/Elastica/Test/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function testResponse()
$type = $index->getType('helloworld');

$mapping = new Mapping($type, [
'name' => ['type' => 'string', 'store' => 'no'],
'dtmPosted' => ['type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'],
'name' => ['type' => 'text'],
'dtmPosted' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'],
]);
$type->setMapping($mapping);

Expand Down
6 changes: 3 additions & 3 deletions test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ public function testGetMapping(array $config, $transport)
'user' => [
'type' => 'object',
'properties' => [
'name' => ['type' => 'string', 'include_in_all' => true],
'fullName' => ['type' => 'string', 'include_in_all' => true],
'name' => ['type' => 'text', 'include_in_all' => true],
'fullName' => ['type' => 'text', 'include_in_all' => true],
],
],
'msg' => ['type' => 'string', 'include_in_all' => true],
'msg' => ['type' => 'text', 'include_in_all' => true],
'tstamp' => ['type' => 'date', 'include_in_all' => false],
'location' => ['type' => 'geo_point', 'include_in_all' => false],
'_boost' => ['type' => 'float', 'include_in_all' => false],
Expand Down
20 changes: 10 additions & 10 deletions test/lib/Elastica/Test/Type/MappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public function testNestedMapping()
'type' => 'object', 'properties' => [
'user' => [
'properties' => [
'firstname' => ['type' => 'string', 'store' => true],
'lastname' => ['type' => 'string', 'store' => true],
'firstname' => ['type' => 'text', 'store' => true],
'lastname' => ['type' => 'text', 'store' => true],
'age' => ['type' => 'integer', 'store' => true],
],
],
Expand Down Expand Up @@ -162,7 +162,7 @@ public function testParentMapping()
$childtype = new Type($index, 'childtype');
$childmapping = new Mapping($childtype,
[
'name' => ['type' => 'string', 'store' => true],
'name' => ['type' => 'text', 'store' => true],
]
);
$childmapping->setParent('parenttype');
Expand All @@ -175,7 +175,7 @@ public function testParentMapping()
$parenttype = new Type($index, 'parenttype');
$parentmapping = new Mapping($parenttype,
[
'name' => ['type' => 'string', 'store' => true],
'name' => ['type' => 'text', 'store' => true],
]
);

Expand All @@ -194,8 +194,8 @@ public function testMappingExample()
[
'note' => [
'properties' => [
'titulo' => ['type' => 'text', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0],
'contenido' => ['type' => 'text', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0],
'titulo' => ['type' => 'text', 'include_in_all' => true, 'boost' => 1.0],
'contenido' => ['type' => 'text', 'include_in_all' => true, 'boost' => 1.0],
],
],
]
Expand Down Expand Up @@ -289,8 +289,8 @@ public function testSetMeta()
$index = $this->_createIndex();
$type = $index->getType('test');
$mapping = new Mapping($type, [
'firstname' => ['type' => 'string', 'store' => true],
'lastname' => ['type' => 'string'],
'firstname' => ['type' => 'text', 'store' => true],
'lastname' => ['type' => 'text'],
]);
$mapping->setMeta(['class' => 'test']);
$type->setMapping($mapping);
Expand All @@ -309,8 +309,8 @@ public function testGetters()
$index = $this->_createIndex();
$type = $index->getType('test');
$properties = [
'firstname' => ['type' => 'string', 'store' => true],
'lastname' => ['type' => 'string'],
'firstname' => ['type' => 'text', 'store' => true],
'lastname' => ['type' => 'text'],
];
$mapping = new Mapping($type, $properties);
$all = [
Expand Down
7 changes: 3 additions & 4 deletions test/lib/Elastica/Test/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function testNoSource()
$type = new Type($index, 'user');
$mapping = new Mapping($type, [
'id' => ['type' => 'integer', 'store' => 'yes'],
'username' => ['type' => 'string', 'store' => 'no'],
'username' => ['type' => 'text'],
]);
$mapping->setSource(['enabled' => false]);
$type->setMapping($mapping);
Expand Down Expand Up @@ -747,11 +747,10 @@ public function testUpdateDocumentWithoutSource()
$mapping = new Mapping();
$mapping->setProperties([
'name' => [
'type' => 'string',
'store' => 'yes', ],
'type' => 'text',
'store' => 'true', ],
'counter' => [
'type' => 'integer',
'store' => 'no',
],
]);
$mapping->disableSource();
Expand Down

0 comments on commit c44ec85

Please sign in to comment.