Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
6080255b
Commit
6080255b
authored
Mar 21, 2013
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added modifier support to createDocument
parent
23a2e15d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
library/Solarium/QueryType/Update/Query/Query.php
library/Solarium/QueryType/Update/Query/Query.php
+5
-4
tests/Solarium/Tests/QueryType/Update/Query/QueryTest.php
tests/Solarium/Tests/QueryType/Update/Query/QueryTest.php
+9
-2
No files found.
library/Solarium/QueryType/Update/Query/Query.php
View file @
6080255b
...
@@ -49,6 +49,7 @@ use Solarium\QueryType\Update\Query\Command\Commit as CommitCommand;
...
@@ -49,6 +49,7 @@ use Solarium\QueryType\Update\Query\Command\Commit as CommitCommand;
use
Solarium\QueryType\Update\Query\Command\Delete
as
DeleteCommand
;
use
Solarium\QueryType\Update\Query\Command\Delete
as
DeleteCommand
;
use
Solarium\QueryType\Update\Query\Command\Optimize
as
OptimizeCommand
;
use
Solarium\QueryType\Update\Query\Command\Optimize
as
OptimizeCommand
;
use
Solarium\QueryType\Update\Query\Command\Rollback
as
RollbackCommand
;
use
Solarium\QueryType\Update\Query\Command\Rollback
as
RollbackCommand
;
use
Solarium\QueryType\Update\Query\Document\DocumentInterface
;
/**
/**
* Update query
* Update query
...
@@ -485,13 +486,13 @@ class Query extends BaseQuery
...
@@ -485,13 +486,13 @@ class Query extends BaseQuery
*
*
* @param array $fields
* @param array $fields
* @param array $boosts
* @param array $boosts
* @return Document
* @param array $modifiers
* @return DocumentInterface
*/
*/
public
function
createDocument
(
$fields
=
array
(),
$boosts
=
array
())
public
function
createDocument
(
$fields
=
array
(),
$boosts
=
array
()
,
$modifiers
=
array
()
)
{
{
$class
=
$this
->
getDocumentClass
();
$class
=
$this
->
getDocumentClass
();
return
new
$class
(
$fields
,
$boosts
,
$modifiers
);
return
new
$class
(
$fields
,
$boosts
);
}
}
}
}
tests/Solarium/Tests/QueryType/Update/Query/QueryTest.php
View file @
6080255b
...
@@ -471,12 +471,14 @@ class QueryTest extends \PHPUnit_Framework_TestCase
...
@@ -471,12 +471,14 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$this
->
assertThat
(
$doc
,
$this
->
isInstanceOf
(
__NAMESPACE__
.
'\\MyCustomDoc'
));
$this
->
assertThat
(
$doc
,
$this
->
isInstanceOf
(
__NAMESPACE__
.
'\\MyCustomDoc'
));
}
}
public
function
testCreateDocumentWithFieldsAndBoosts
()
public
function
testCreateDocumentWithFieldsAndBoosts
AndModifiers
()
{
{
$fields
=
array
(
'id'
=>
1
,
'name'
=>
'testname'
);
$fields
=
array
(
'id'
=>
1
,
'name'
=>
'testname'
);
$boosts
=
array
(
'name'
=>
2.7
);
$boosts
=
array
(
'name'
=>
2.7
);
$modifiers
=
array
(
'name'
=>
'set'
);
$doc
=
$this
->
query
->
createDocument
(
$fields
,
$boosts
);
$doc
=
$this
->
query
->
createDocument
(
$fields
,
$boosts
,
$modifiers
);
$doc
->
setKey
(
'id'
);
$this
->
assertThat
(
$doc
,
$this
->
isInstanceOf
(
$this
->
query
->
getDocumentClass
()));
$this
->
assertThat
(
$doc
,
$this
->
isInstanceOf
(
$this
->
query
->
getDocumentClass
()));
...
@@ -489,6 +491,11 @@ class QueryTest extends \PHPUnit_Framework_TestCase
...
@@ -489,6 +491,11 @@ class QueryTest extends \PHPUnit_Framework_TestCase
2.7
,
2.7
,
$doc
->
getFieldBoost
(
'name'
)
$doc
->
getFieldBoost
(
'name'
)
);
);
$this
->
assertEquals
(
$modifiers
[
'name'
],
$doc
->
getFieldModifier
(
'name'
)
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment