Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:basdenooijer/solarium into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
basdenooijer committed Nov 4, 2014
2 parents 2015a57 + 2acf137 commit df971be
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
20 changes: 20 additions & 0 deletions library/Solarium/QueryType/Extract/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Query extends BaseQuery
'resultclass' => 'Solarium\QueryType\Extract\Result',
'documentclass' => 'Solarium\QueryType\Update\Query\Document\Document',
'omitheader' => true,
'extractonly' => false,
);

/**
Expand Down Expand Up @@ -387,6 +388,25 @@ public function getDocumentClass()
return $this->getOption('documentclass');
}

/**
* Set the ExtractOnly parameter of SOLR Extraction Handler
*
* @param bool $value
* @return self Provides fluent interface
*/
public function setExtractOnly($value) {
return $this->setOption('extractonly', (bool) $value);
}

/**
* Get the ExtractOnly parameter of SOLR Extraction Handler
*
* @return boolean
*/
public function getExtractOnly() {
return $this->getOption('extractonly');
}

/**
* Create a document object instance
*
Expand Down
1 change: 1 addition & 0 deletions library/Solarium/QueryType/Extract/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function build(QueryInterface $query)
$request->addParam('uprefix', $query->getUprefix());
$request->addParam('lowernames', $query->getLowernames());
$request->addParam('defaultField', $query->getDefaultField());
$request->addParam('extractOnly', $query->getExtractOnly());

foreach ($query->getFieldMappings() as $fromField => $toField) {
$request->addParam('fmap.' . $fromField, $toField);
Expand Down
6 changes: 6 additions & 0 deletions tests/Solarium/Tests/QueryType/Extract/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public function testSetAndGetDefaultField()
$this->assertEquals('defaulttext', $this->query->getDefaultField());
}

public function testSetAndGetExtractOnly()
{
$this->query->setExtractOnly(true);
$this->assertEquals(true, $this->query->getExtractOnly());
}

public function testSetAndGetLowernames()
{
$this->query->setLowernames(true);
Expand Down
5 changes: 3 additions & 2 deletions tests/Solarium/Tests/QueryType/Extract/RequestBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testGetUri()
{
$request = $this->builder->build($this->query);
$this->assertEquals(
'update/extract?omitHeader=true&param1=value1&wt=json&json.nl=flat&fmap.from-field=to-field'.
'update/extract?omitHeader=true&param1=value1&wt=json&json.nl=flat&extractOnly=false&fmap.from-field=to-field'.
'&resource.name=RequestBuilderTest.php',
$request->getUri()
);
Expand All @@ -90,7 +90,7 @@ public function testGetUriWithStreamUrl()
$query->setFile('http://solarium-project.org/');
$request = $this->builder->build($query);
$this->assertEquals(
'update/extract?omitHeader=true&param1=value1&wt=json&json.nl=flat&fmap.from-field=to-field'.
'update/extract?omitHeader=true&param1=value1&wt=json&json.nl=flat&extractOnly=false&fmap.from-field=to-field'.
'&stream.url=http%3A%2F%2Fsolarium-project.org%2F',
$request->getUri()
);
Expand All @@ -112,6 +112,7 @@ public function testDocumentFieldAndBoostParams()
'literal.field1' => 'value1',
'literal.field2' => 'value2',
'omitHeader' => 'true',
'extractOnly' => 'false',
'param1' => 'value1',
'resource.name' => 'RequestBuilderTest.php',
'wt' => 'json',
Expand Down

0 comments on commit df971be

Please sign in to comment.