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
5cf3455e
Commit
5cf3455e
authored
May 15, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/new-structure' of github.com:basdenooijer/solarium into feature/new-structure
parents
8726216f
a46a0ca7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
136 additions
and
16 deletions
+136
-16
library/Solarium/Document/ReadWrite.php
library/Solarium/Document/ReadWrite.php
+13
-0
library/Solarium/Query/Update/Command/Add.php
library/Solarium/Query/Update/Command/Add.php
+20
-6
library/Solarium/Query/Update/Command/Commit.php
library/Solarium/Query/Update/Command/Commit.php
+3
-3
library/Solarium/Query/Update/Command/Delete.php
library/Solarium/Query/Update/Command/Delete.php
+4
-4
library/Solarium/Query/Update/Command/Optimize.php
library/Solarium/Query/Update/Command/Optimize.php
+3
-3
tests/Solarium/Document/ReadWriteTest.php
tests/Solarium/Document/ReadWriteTest.php
+25
-0
tests/Solarium/Query/Update/Command/AddTest.php
tests/Solarium/Query/Update/Command/AddTest.php
+68
-0
No files found.
library/Solarium/Document/ReadWrite.php
View file @
5cf3455e
...
@@ -202,6 +202,19 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
...
@@ -202,6 +202,19 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
return
$this
->
_boost
;
return
$this
->
_boost
;
}
}
/**
* Clear all fields
*
* @return Solarium_Document_ReadWrite Provides fluent interface
**/
public
function
clear
()
{
$this
->
_fields
=
array
();
$this
->
_fieldBoosts
=
array
();
return
$this
;
}
/**
/**
* Set field value
* Set field value
*
*
...
...
library/Solarium/Query/Update/Command/Add.php
View file @
5cf3455e
...
@@ -68,7 +68,7 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
...
@@ -68,7 +68,7 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
* Add a single document
* Add a single document
*
*
* @param object $document
* @param object $document
* @return Solarium_Query_Update_Add Provides fluent interface
* @return Solarium_Query_Update_
Command_
Add Provides fluent interface
*/
*/
public
function
addDocument
(
$document
)
public
function
addDocument
(
$document
)
{
{
...
@@ -80,12 +80,26 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
...
@@ -80,12 +80,26 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
/**
/**
* Add multiple documents
* Add multiple documents
*
*
* @param array $documents
* @param array
|Traversable
$documents
* @return Solarium_Query_Update_Add Provides fluent interface
* @return Solarium_Query_Update_
Command_
Add Provides fluent interface
*/
*/
public
function
addDocuments
(
$documents
)
public
function
addDocuments
(
$documents
)
{
{
$this
->
_documents
=
array_merge
(
$this
->
_documents
,
$documents
);
//if we don't have documents so far, accept arrays or Traversable objects as-is
if
(
empty
(
$this
->
_documents
))
{
$this
->
_documents
=
$documents
;
return
$this
;
}
//if something Traversable is passed in, and there are existing documents, convert all to arrays before merging
if
(
$documents
instanceof
Traversable
)
{
$documents
=
iterator_to_array
(
$documents
);
}
if
(
$this
->
_documents
instanceof
Traversable
)
{
$this
->
_documents
=
array_merge
(
iterator_to_array
(
$this
->
_documents
),
$documents
);
}
else
{
$this
->
_documents
=
array_merge
(
$this
->
_documents
,
$documents
);
}
return
$this
;
return
$this
;
}
}
...
@@ -104,7 +118,7 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
...
@@ -104,7 +118,7 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
* Set overwrite option
* Set overwrite option
*
*
* @param boolean $overwrite
* @param boolean $overwrite
* @return Solarium_Query_Update_Add Provides fluent interface
* @return Solarium_Query_Update_
Command_
Add Provides fluent interface
*/
*/
public
function
setOverwrite
(
$overwrite
)
public
function
setOverwrite
(
$overwrite
)
{
{
...
@@ -125,7 +139,7 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
...
@@ -125,7 +139,7 @@ class Solarium_Query_Update_Command_Add extends Solarium_Query_Update_Command
* Get commitWithin option
* Get commitWithin option
*
*
* @param boolean $commitWithin
* @param boolean $commitWithin
* @return Solarium_Query_Update_Add Provides fluent interface
* @return Solarium_Query_Update_
Command_
Add Provides fluent interface
*/
*/
public
function
setCommitWithin
(
$commitWithin
)
public
function
setCommitWithin
(
$commitWithin
)
{
{
...
...
library/Solarium/Query/Update/Command/Commit.php
View file @
5cf3455e
...
@@ -71,7 +71,7 @@ class Solarium_Query_Update_Command_Commit extends Solarium_Query_Update_Command
...
@@ -71,7 +71,7 @@ class Solarium_Query_Update_Command_Commit extends Solarium_Query_Update_Command
* Set waitFlush option
* Set waitFlush option
*
*
* @param boolean $waitFlush
* @param boolean $waitFlush
* @return Solarium_Query_Update_Commit Provides fluent interface
* @return Solarium_Query_Update_Comm
and_Comm
it Provides fluent interface
*/
*/
public
function
setWaitFlush
(
$waitFlush
)
public
function
setWaitFlush
(
$waitFlush
)
{
{
...
@@ -92,7 +92,7 @@ class Solarium_Query_Update_Command_Commit extends Solarium_Query_Update_Command
...
@@ -92,7 +92,7 @@ class Solarium_Query_Update_Command_Commit extends Solarium_Query_Update_Command
* Set waitSearcher option
* Set waitSearcher option
*
*
* @param boolean $waitSearcher
* @param boolean $waitSearcher
* @return Solarium_Query_Update_Commit Provides fluent interface
* @return Solarium_Query_Update_Comm
and_Comm
it Provides fluent interface
*/
*/
public
function
setWaitSearcher
(
$waitSearcher
)
public
function
setWaitSearcher
(
$waitSearcher
)
{
{
...
@@ -113,7 +113,7 @@ class Solarium_Query_Update_Command_Commit extends Solarium_Query_Update_Command
...
@@ -113,7 +113,7 @@ class Solarium_Query_Update_Command_Commit extends Solarium_Query_Update_Command
* Set expungeDeletes option
* Set expungeDeletes option
*
*
* @param boolean $expungeDeletes
* @param boolean $expungeDeletes
* @return Solarium_Query_Update_Commit Provides fluent interface
* @return Solarium_Query_Update_Comm
and_Comm
it Provides fluent interface
*/
*/
public
function
setExpungeDeletes
(
$expungeDeletes
)
public
function
setExpungeDeletes
(
$expungeDeletes
)
{
{
...
...
library/Solarium/Query/Update/Command/Delete.php
View file @
5cf3455e
...
@@ -101,7 +101,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
...
@@ -101,7 +101,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
* Add a single ID to the delete command
* Add a single ID to the delete command
*
*
* @param int|string $id
* @param int|string $id
* @return Solarium_Query_Update_Delete Provides fluent interface
* @return Solarium_Query_Update_
Command_
Delete Provides fluent interface
*/
*/
public
function
addId
(
$id
)
public
function
addId
(
$id
)
{
{
...
@@ -114,7 +114,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
...
@@ -114,7 +114,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
* Add multiple IDs to the delete command
* Add multiple IDs to the delete command
*
*
* @param array $id
* @param array $id
* @return Solarium_Query_Update_Delete Provides fluent interface
* @return Solarium_Query_Update_
Command_
Delete Provides fluent interface
*/
*/
public
function
addIds
(
$ids
)
public
function
addIds
(
$ids
)
{
{
...
@@ -127,7 +127,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
...
@@ -127,7 +127,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
* Add a single query to the delete command
* Add a single query to the delete command
*
*
* @param string $query
* @param string $query
* @return Solarium_Query_Update_Delete Provides fluent interface
* @return Solarium_Query_Update_
Command_
Delete Provides fluent interface
*/
*/
public
function
addQuery
(
$query
)
public
function
addQuery
(
$query
)
{
{
...
@@ -140,7 +140,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
...
@@ -140,7 +140,7 @@ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
* Add multiple queries to the delete command
* Add multiple queries to the delete command
*
*
* @param array $queries
* @param array $queries
* @return Solarium_Query_Update_Delete Provides fluent interface
* @return Solarium_Query_Update_
Command_
Delete Provides fluent interface
*/
*/
public
function
addQueries
(
$queries
)
public
function
addQueries
(
$queries
)
{
{
...
...
library/Solarium/Query/Update/Command/Optimize.php
View file @
5cf3455e
...
@@ -71,7 +71,7 @@ class Solarium_Query_Update_Command_Optimize
...
@@ -71,7 +71,7 @@ class Solarium_Query_Update_Command_Optimize
* Set waitFlush option
* Set waitFlush option
*
*
* @param boolean $waitFlush
* @param boolean $waitFlush
* @return Solarium_Query_Update_Optimize Provides fluent interface
* @return Solarium_Query_Update_
Command_
Optimize Provides fluent interface
*/
*/
public
function
setWaitFlush
(
$waitFlush
)
public
function
setWaitFlush
(
$waitFlush
)
{
{
...
@@ -92,7 +92,7 @@ class Solarium_Query_Update_Command_Optimize
...
@@ -92,7 +92,7 @@ class Solarium_Query_Update_Command_Optimize
* Set waitSearcher option
* Set waitSearcher option
*
*
* @param boolean $waitSearcher
* @param boolean $waitSearcher
* @return Solarium_Query_Update_Optimize Provides fluent interface
* @return Solarium_Query_Update_
Command_
Optimize Provides fluent interface
*/
*/
public
function
setWaitSearcher
(
$waitSearcher
)
public
function
setWaitSearcher
(
$waitSearcher
)
{
{
...
@@ -113,7 +113,7 @@ class Solarium_Query_Update_Command_Optimize
...
@@ -113,7 +113,7 @@ class Solarium_Query_Update_Command_Optimize
* Set maxSegments option
* Set maxSegments option
*
*
* @param boolean $maxSegments
* @param boolean $maxSegments
* @return Solarium_Query_Update_Optimize Provides fluent interface
* @return Solarium_Query_Update_
Command_
Optimize Provides fluent interface
*/
*/
public
function
setMaxSegments
(
$maxSegments
)
public
function
setMaxSegments
(
$maxSegments
)
{
{
...
...
tests/Solarium/Document/ReadWriteTest.php
View file @
5cf3455e
...
@@ -272,5 +272,30 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
...
@@ -272,5 +272,30 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
$this
->
_doc
->
getFields
()
$this
->
_doc
->
getFields
()
);
);
}
}
public
function
testClearFields
()
{
$this
->
_doc
->
clear
();
$expectedFields
=
array
();
$this
->
assertEquals
(
$expectedFields
,
$this
->
_doc
->
getFields
()
);
}
public
function
testClearFieldsBoostRemoval
()
{
$this
->
_doc
->
setFieldBoost
(
'name'
,
3.2
);
$this
->
_doc
->
clear
();
$expectedFields
=
array
();
$this
->
assertEquals
(
null
,
$this
->
_doc
->
getFieldBoost
(
'name'
)
);
}
}
}
tests/Solarium/Query/Update/Command/AddTest.php
View file @
5cf3455e
...
@@ -67,6 +67,74 @@ class Solarium_Query_Update_Command_AddTest extends PHPUnit_Framework_TestCase
...
@@ -67,6 +67,74 @@ class Solarium_Query_Update_Command_AddTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testAddDocumentsIteration
()
{
$doc1
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
1
));
$doc2
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
2
));
$it
=
new
ArrayIterator
(
array
(
$doc1
,
$doc2
));
$this
->
_command
->
addDocuments
(
$it
);
if
(
$this
->
_command
->
getDocuments
()
instanceof
Traversable
)
{
$command_documents
=
iterator_to_array
(
$this
->
_command
->
getDocuments
());
}
else
{
$command_documents
=
$this
->
_command
->
getDocuments
();
}
$this
->
assertEquals
(
array
(
$doc1
,
$doc2
),
$command_documents
,
'checking first two documents are added correctly'
);
$doc3
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
3
));
$doc4
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
4
));
$doc5
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
5
));
$it2
=
new
ArrayIterator
(
array
(
$doc3
,
$doc4
,
$doc5
));
$this
->
_command
->
addDocuments
(
$it2
);
if
(
$this
->
_command
->
getDocuments
()
instanceof
Traversable
)
{
$command_documents
=
iterator_to_array
(
$this
->
_command
->
getDocuments
());
}
else
{
$command_documents
=
$this
->
_command
->
getDocuments
();
}
$this
->
assertEquals
(
array
(
$doc1
,
$doc2
,
$doc3
,
$doc4
,
$doc5
),
$command_documents
,
'checking second three documents are added correctly to first two'
);
}
/**
* @depends testAddDocumentsIteration
*/
public
function
testAddDocumentToIteration
()
{
$doc1
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
1
));
$doc2
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
2
));
$this
->
_command
->
addDocuments
(
new
ArrayIterator
(
array
(
$doc1
,
$doc2
)));
$doc3
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
3
));
$this
->
_command
->
addDocument
(
$doc3
);
if
(
$this
->
_command
->
getDocuments
()
instanceof
Traversable
)
{
$command_documents
=
iterator_to_array
(
$this
->
_command
->
getDocuments
());
}
else
{
$command_documents
=
$this
->
_command
->
getDocuments
();
}
$this
->
assertEquals
(
array
(
$doc1
,
$doc2
,
$doc3
),
$command_documents
);
}
public
function
testGetAndSetOverwrite
()
public
function
testGetAndSetOverwrite
()
{
{
$this
->
_command
->
setOverwrite
(
false
);
$this
->
_command
->
setOverwrite
(
false
);
...
...
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