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
ddab0592
Commit
ddab0592
authored
Aug 05, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/2.1.0' into develop
parents
daec42c3
e172617d
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
86 additions
and
24 deletions
+86
-24
examples/1.3-basic-update.php
examples/1.3-basic-update.php
+7
-7
examples/3.1-add-docs.php
examples/3.1-add-docs.php
+7
-8
examples/6.2-escaping.php
examples/6.2-escaping.php
+1
-0
examples/6.3-demo-app.php
examples/6.3-demo-app.php
+0
-8
examples/6.3-placeholder-syntax.php
examples/6.3-placeholder-syntax.php
+45
-0
examples/index.html
examples/index.html
+1
-1
library/Solarium/Query/Helper.php
library/Solarium/Query/Helper.php
+9
-0
library/Solarium/Query/Select/Component/DisMax.php
library/Solarium/Query/Select/Component/DisMax.php
+4
-0
library/Solarium/Query/Select/Component/Grouping.php
library/Solarium/Query/Select/Component/Grouping.php
+2
-0
library/Solarium/Query/Update.php
library/Solarium/Query/Update.php
+2
-0
library/Solarium/Result/Select/Grouping.php
library/Solarium/Result/Select/Grouping.php
+2
-0
library/Solarium/Result/Select/Grouping/FieldGroup.php
library/Solarium/Result/Select/Grouping/FieldGroup.php
+2
-0
library/Solarium/Result/Select/Grouping/QueryGroup.php
library/Solarium/Result/Select/Grouping/QueryGroup.php
+2
-0
library/Solarium/Result/Select/Grouping/ValueGroup.php
library/Solarium/Result/Select/Grouping/ValueGroup.php
+2
-0
No files found.
examples/1.3-basic-update.php
View file @
ddab0592
...
...
@@ -6,19 +6,19 @@ htmlHeader();
if
(
$_POST
)
{
// if data is posted add it to solr
// create a new document for the data
// please note that any type of validation is missing in this example to keep it simple!
$doc
=
new
Solarium_Document_ReadWrite
();
$doc
->
id
=
$_POST
[
'id'
];
$doc
->
name
=
$_POST
[
'name'
];
$doc
->
price
=
$_POST
[
'price'
];
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get an update query instance
$update
=
$client
->
createUpdate
();
// create a new document for the data
// please note that any type of validation is missing in this example to keep it simple!
$doc
=
$update
->
createDocument
();
$doc
->
id
=
$_POST
[
'id'
];
$doc
->
name
=
$_POST
[
'name'
];
$doc
->
price
=
$_POST
[
'price'
];
// add the document and a commit command to the update query
$update
->
addDocument
(
$doc
);
$update
->
addCommit
();
...
...
examples/3.1-add-docs.php
View file @
ddab0592
...
...
@@ -3,25 +3,24 @@
require
(
'init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get an update query instance
$update
=
$client
->
createUpdate
();
// create a new document for the data
$doc1
=
new
Solarium_Document_ReadWrite
();
$doc1
=
$update
->
createDocument
();
$doc1
->
id
=
123
;
$doc1
->
name
=
'testdoc-1'
;
$doc1
->
price
=
364
;
// and a second one
$doc2
=
new
Solarium_Document_ReadWrite
();
$doc2
=
$update
->
createDocument
();
$doc2
->
id
=
124
;
$doc2
->
name
=
'testdoc-2'
;
$doc2
->
price
=
340
;
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get an update query instance
$update
=
$client
->
createUpdate
();
// add the documents and a commit command to the update query
$update
->
addDocuments
(
array
(
$doc1
,
$doc2
));
$update
->
addCommit
();
...
...
examples/6.2-escaping.php
View file @
ddab0592
...
...
@@ -13,6 +13,7 @@ $query = $client->createSelect();
$input
=
'ATA "133'
;
// in this case phrase escaping is used (most common) but you can also do term escaping, see the manual
// also note that the same can be done using the placeholder syntax, see example 6.3
$helper
=
$query
->
getHelper
();
$query
->
setQuery
(
'features:'
.
$helper
->
escapePhrase
(
$input
));
...
...
examples/6.3-demo-app.php
deleted
100644 → 0
View file @
daec42c3
<?php
require
(
'init.php'
);
htmlHeader
();
echo
'TODO'
;
htmlFooter
();
\ No newline at end of file
examples/6.3-placeholder-syntax.php
0 → 100644
View file @
ddab0592
<?php
require
(
'init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get a select query instance
$query
=
$client
->
createSelect
();
// search input string, this value fails without escaping because of the double-quote
$input
=
'ATA "133'
;
// the placeholder syntax applies phrase escaping to the first term
// see the manual for all supported formats
$query
->
setQuery
(
'features: %p1% AND inStock:%2%'
,
array
(
$input
,
1
));
// show the result after replacing the placeholders with values
echo
$query
->
getQuery
()
.
'<br/>'
;
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
// display the total number of documents found by solr
echo
'NumFound: '
.
$resultset
->
getNumFound
();
// show documents using the resultset iterator
foreach
(
$resultset
as
$document
)
{
echo
'<hr/><table>'
;
// the documents are also iterable, to get all fields
foreach
(
$document
AS
$field
=>
$value
)
{
// this converts multivalue fields to a comma-separated string
if
(
is_array
(
$value
))
$value
=
implode
(
', '
,
$value
);
echo
'<tr><th>'
.
$field
.
'</th><td>'
.
$value
.
'</td></tr>'
;
}
echo
'</table>'
;
}
htmlFooter
();
\ No newline at end of file
examples/index.html
View file @
ddab0592
...
...
@@ -82,7 +82,7 @@
<ul
style=
"list-style:none;"
>
<li><a
href=
"6.1-zend-http-adapter.php"
>
6.1 Zend_Http adapter
</a></li>
<li><a
href=
"6.2-escaping.php"
>
6.2 Escaping
</a></li>
<li><a
href=
"6.3-
demo-app.php"
>
2.7 Demo search (mini) application
</a></li>
<li><a
href=
"6.3-
placeholder-syntax.php"
>
6.3 Placeholder syntax
</a></li>
</ul>
</ul>
...
...
library/Solarium/Query/Helper.php
View file @
ddab0592
...
...
@@ -249,6 +249,8 @@ class Solarium_Query_Helper
* The mode matching pattern can be customized by overriding the
* value of $this->_placeHolderPattern
*
* @since 2.1.0
*
* @param string $query
* @param array $parts Array of strings
* @return string
...
...
@@ -264,6 +266,13 @@ class Solarium_Query_Helper
);
}
/**
* Render placeholders in a querystring
*
* @throws Solarium_Exception
* @param array $matches
* @return string
*/
protected
function
_renderPlaceHolder
(
$matches
)
{
$partNumber
=
$matches
[
2
];
...
...
library/Solarium/Query/Select/Component/DisMax.php
View file @
ddab0592
...
...
@@ -290,6 +290,8 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
*
* Can be used to enable edismax
*
* @since 2.1.0
*
* @param string $parser
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
...
...
@@ -301,6 +303,8 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
/**
* Get QueryParser option
*
* @since 2.1.0
*
* @return string
*/
public
function
getQueryParser
()
...
...
library/Solarium/Query/Select/Component/Grouping.php
View file @
ddab0592
...
...
@@ -44,6 +44,8 @@
*
* @link http://wiki.apache.org/solr/FieldCollapsing
*
* @since 2.1.0
*
* @package Solarium
* @subpackage Query
*/
...
...
library/Solarium/Query/Update.php
View file @
ddab0592
...
...
@@ -392,6 +392,8 @@ class Solarium_Query_Update extends Solarium_Query
* You can optionally directly supply the fields and boosts
* to get a ready-made document instance for direct use in an add command
*
* @since 2.1.0
*
* @param array $fields
* @param array $boosts
* @return Solarium_Document_ReadWrite
...
...
library/Solarium/Result/Select/Grouping.php
View file @
ddab0592
...
...
@@ -39,6 +39,8 @@
/**
* Select component grouping result
*
* @since 2.1.0
*
* @package Solarium
* @subpackage Result
*/
...
...
library/Solarium/Result/Select/Grouping/FieldGroup.php
View file @
ddab0592
...
...
@@ -39,6 +39,8 @@
/**
* Select component grouping field group result
*
* @since 2.1.0
*
* @package Solarium
* @subpackage Result
*/
...
...
library/Solarium/Result/Select/Grouping/QueryGroup.php
View file @
ddab0592
...
...
@@ -39,6 +39,8 @@
/**
* Select component grouping query group result
*
* @since 2.1.0
*
* @package Solarium
* @subpackage Result
*/
...
...
library/Solarium/Result/Select/Grouping/ValueGroup.php
View file @
ddab0592
...
...
@@ -39,6 +39,8 @@
/**
* Select component grouping field value group result
*
* @since 2.1.0
*
* @package Solarium
* @subpackage Result
*/
...
...
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