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
4dcfb999
Commit
4dcfb999
authored
Jul 23, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added extract example, first working version. Still needs more work though
parent
fb830050
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
6 deletions
+80
-6
examples/2.7-extract-query.php
examples/2.7-extract-query.php
+31
-0
examples/index.html
examples/index.html
+1
-0
library/Solarium/Core/Client/Adapter/ZendHttp.php
library/Solarium/Core/Client/Adapter/ZendHttp.php
+0
-1
library/Solarium/Core/Client/Client.php
library/Solarium/Core/Client/Client.php
+1
-1
library/Solarium/QueryType/Extract/Query.php
library/Solarium/QueryType/Extract/Query.php
+47
-4
No files found.
examples/2.7-extract-query.php
0 → 100644
View file @
4dcfb999
<?php
require
(
__DIR__
.
'/init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium\Client
(
$config
);
$client
->
setAdapter
(
'Solarium\Core\Client\Adapter\ZendHttp'
);
// get an extract query instance and add settings
$query
=
$client
->
createExtract
();
$query
->
addFieldMapping
(
'content'
,
'text'
);
$query
->
setUprefix
(
'attr_'
);
$query
->
setFile
(
__DIR__
.
'/index.html'
);
$query
->
setCommit
(
true
);
$query
->
setOmitHeader
(
false
);
// add document
$doc
=
$query
->
createDocument
();
$doc
->
id
=
time
();
$doc
->
some
=
'more fields'
;
$query
->
setDocument
(
$doc
);
// this executes the query and returns the result
$result
=
$client
->
extract
(
$query
);
echo
'<b>Extract query executed</b><br/>'
;
echo
'Query status: '
.
$result
->
getStatus
()
.
'<br/>'
;
echo
'Query time: '
.
$result
->
getQueryTime
();
htmlFooter
();
\ No newline at end of file
examples/index.html
View file @
4dcfb999
...
...
@@ -85,6 +85,7 @@
<li><a
href=
"2.5-terms-query.php"
>
2.5 Terms query
</a></li>
<li><a
href=
"2.6-suggester-query.php"
>
2.6 Suggester query
</a></li>
<li><a
href=
"2.7-extract-query.php"
>
2.7 Extract query
</a></li>
</ul>
<li>
4. Usage modes
</li>
...
...
library/Solarium/Core/Client/Adapter/ZendHttp.php
View file @
4dcfb999
...
...
@@ -178,7 +178,6 @@ class ZendHttp extends Configurable implements AdapterInterface
break
;
case
Request
::
METHOD_POST
:
$client
->
setMethod
(
\Zend_Http_Client
::
POST
);
if
(
$request
->
getFileUpload
())
{
$this
->
prepareFileUpload
(
$client
,
$request
);
}
else
{
...
...
library/Solarium/Core/Client/Client.php
View file @
4dcfb999
...
...
@@ -1088,6 +1088,6 @@ class Client extends Configurable
*/
public
function
createExtract
(
$options
=
null
)
{
return
$this
->
create
Extract
(
self
::
QUERY_EXTRACT
,
$options
);
return
$this
->
create
Query
(
self
::
QUERY_EXTRACT
,
$options
);
}
}
library/Solarium/QueryType/Extract/Query.php
View file @
4dcfb999
...
...
@@ -66,9 +66,10 @@ class Query extends BaseQuery
*
* @var array
*/
protected
$
_
options
=
array
(
protected
$options
=
array
(
'handler'
=>
'update/extract'
,
'resultclass'
=>
'Solarium\QueryType\Extract\Result'
,
'documentclass'
=>
'Solarium\QueryType\Update\Query\Document'
,
'omitheader'
=>
true
,
);
...
...
@@ -117,10 +118,10 @@ class Query extends BaseQuery
*
* @return void
*/
protected
function
_
init
()
protected
function
init
()
{
if
(
isset
(
$this
->
_
options
[
'fmap'
]))
{
$this
->
setFieldMappings
(
$this
->
_
options
[
'fmap'
]);
if
(
isset
(
$this
->
options
[
'fmap'
]))
{
$this
->
setFieldMappings
(
$this
->
options
[
'fmap'
]);
}
}
...
...
@@ -358,4 +359,46 @@ class Query extends BaseQuery
return
$this
;
}
/**
* Set a custom document class for use in the createDocument method
*
* This class should implement the document interface
*
* @param string $value classname
* @return self Provides fluent interface
*/
public
function
setDocumentClass
(
$value
)
{
return
$this
->
setOption
(
'documentclass'
,
$value
);
}
/**
* Get the current documentclass option
*
* The value is a classname, not an instance
*
* @return string
*/
public
function
getDocumentClass
()
{
return
$this
->
getOption
(
'documentclass'
);
}
/**
* Create a document object instance
*
* You can optionally directly supply the fields and boosts
* to get a ready-made document instance for direct use in an add command
*
* @param array $fields
* @param array $boosts
* @return Document
*/
public
function
createDocument
(
$fields
=
array
(),
$boosts
=
array
())
{
$class
=
$this
->
getDocumentClass
();
return
new
$class
(
$fields
,
$boosts
);
}
}
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