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
1505777f
Commit
1505777f
authored
Sep 02, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added analysis examples
parent
d9bbc189
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
0 deletions
+170
-0
examples/2.4.1-analysis-document.php
examples/2.4.1-analysis-document.php
+92
-0
examples/2.4.2-analysis-field.php
examples/2.4.2-analysis-field.php
+72
-0
examples/index.html
examples/index.html
+6
-0
No files found.
examples/2.4.1-analysis-document.php
0 → 100644
View file @
1505777f
<?php
require
(
'init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get an analysis document query
$query
=
$client
->
createAnalysisDocument
();
$query
->
setShowMatch
(
true
);
$query
->
setQuery
(
'ipod'
);
$doc
=
new
Solarium_Document_ReadWrite
(
array
(
'id'
=>
'MA147LL'
,
'name'
=>
'Apple 60 GB iPod with Video Playback Black'
,
'manu'
=>
'Apple Computer Inc.'
,
'cat'
=>
'electronics'
,
'cat'
=>
'music'
,
'features'
=>
'iTunes, Podcasts, Audiobooks'
,
'features'
=>
'Stores up to 15,000 songs, 25,000 photos, or 150 hours of video'
,
'features'
=>
'2.5-inch, 320x240 color TFT LCD display with LED backlight'
,
'features'
=>
'Up to 20 hours of battery life'
,
'features'
=>
'Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video'
,
'features'
=>
'Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication'
,
'includes'
=>
'earbud headphones, USB cable'
,
'weight'
=>
5.5
,
'price'
=>
399.00
,
'popularity'
=>
10
,
'inStock'
=>
true
,
)
);
$query
->
addDocument
(
$doc
);
// this executes the query and returns the result
$result
=
$client
->
analyze
(
$query
);
// show the results
foreach
(
$result
as
$document
)
{
echo
'<hr><h2>Document: '
.
$document
->
getName
()
.
'</h2>'
;
foreach
(
$document
as
$field
)
{
echo
'<h3>Field: '
.
$field
->
getName
()
.
'</h3>'
;
$indexAnalysis
=
$field
->
getIndexAnalysis
();
if
(
!
empty
(
$indexAnalysis
))
{
echo
'<h4>Index Analysis</h4>'
;
foreach
(
$indexAnalysis
as
$classes
)
{
echo
'<h5>'
.
$classes
->
getName
()
.
'</h5>'
;
foreach
(
$classes
as
$result
)
{
echo
'Text: '
.
$result
->
getText
()
.
'<br/>'
;
echo
'Raw text: '
.
$result
->
getRawText
()
.
'<br/>'
;
echo
'Start: '
.
$result
->
getStart
()
.
'<br/>'
;
echo
'End: '
.
$result
->
getEnd
()
.
'<br/>'
;
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
}
$queryAnalysis
=
$field
->
getQueryAnalysis
();
if
(
!
empty
(
$queryAnalysis
))
{
echo
'<h4>Query Analysis</h4>'
;
foreach
(
$queryAnalysis
as
$classes
)
{
echo
'<h5>'
.
$classes
->
getName
()
.
'</h5>'
;
foreach
(
$classes
as
$result
)
{
echo
'Text: '
.
$result
->
getText
()
.
'<br/>'
;
echo
'Raw text: '
.
$result
->
getRawText
()
.
'<br/>'
;
echo
'Start: '
.
$result
->
getStart
()
.
'<br/>'
;
echo
'End: '
.
$result
->
getEnd
()
.
'<br/>'
;
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
}
}
}
htmlFooter
();
\ No newline at end of file
examples/2.4.2-analysis-field.php
0 → 100644
View file @
1505777f
<?php
require
(
'init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get an analysis document query
$query
=
$client
->
createAnalysisField
();
$query
->
setShowMatch
(
true
);
$query
->
setFieldName
(
'cat,title'
);
$query
->
setFieldType
(
'text_general'
);
$query
->
setFieldValue
(
'Apple 60 GB iPod with Video Playback Black'
);
$query
->
setQuery
(
'ipod'
);
// this executes the query and returns the result
$results
=
$client
->
analyze
(
$query
);
// show the results
foreach
(
$results
as
$result
)
{
echo
'<hr><h2>Result list: '
.
$result
->
getName
()
.
'</h2>'
;
foreach
(
$result
as
$item
)
{
echo
'<h3>Item: '
.
$item
->
getName
()
.
'</h3>'
;
$indexAnalysis
=
$item
->
getIndexAnalysis
();
if
(
!
empty
(
$indexAnalysis
))
{
echo
'<h4>Index Analysis</h4>'
;
foreach
(
$indexAnalysis
as
$classes
)
{
echo
'<h5>'
.
$classes
->
getName
()
.
'</h5>'
;
foreach
(
$classes
as
$result
)
{
echo
'Text: '
.
$result
->
getText
()
.
'<br/>'
;
echo
'Raw text: '
.
$result
->
getRawText
()
.
'<br/>'
;
echo
'Start: '
.
$result
->
getStart
()
.
'<br/>'
;
echo
'End: '
.
$result
->
getEnd
()
.
'<br/>'
;
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
}
$queryAnalysis
=
$item
->
getQueryAnalysis
();
if
(
!
empty
(
$queryAnalysis
))
{
echo
'<h4>Query Analysis</h4>'
;
foreach
(
$queryAnalysis
as
$classes
)
{
echo
'<h5>'
.
$classes
->
getName
()
.
'</h5>'
;
foreach
(
$classes
as
$result
)
{
echo
'Text: '
.
$result
->
getText
()
.
'<br/>'
;
echo
'Raw text: '
.
$result
->
getRawText
()
.
'<br/>'
;
echo
'Start: '
.
$result
->
getStart
()
.
'<br/>'
;
echo
'End: '
.
$result
->
getEnd
()
.
'<br/>'
;
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
}
}
}
htmlFooter
();
\ No newline at end of file
examples/index.html
View file @
1505777f
...
@@ -67,6 +67,12 @@
...
@@ -67,6 +67,12 @@
<li><a
href=
"2.3.1-mlt-query.php"
>
2.3.1 MoreLikeThis query
</a></li>
<li><a
href=
"2.3.1-mlt-query.php"
>
2.3.1 MoreLikeThis query
</a></li>
<li><a
href=
"2.3.2-mlt-stream.php"
>
2.3.2 MoreLikeThis query input as stream
</a></li>
<li><a
href=
"2.3.2-mlt-stream.php"
>
2.3.2 MoreLikeThis query input as stream
</a></li>
</ul>
</ul>
<li>
2.4. Analysis queries
</li>
<ul
style=
"list-style:none;"
>
<li><a
href=
"2.4.1-analysis-document.php"
>
2.4.1 Analysis query for a document
</a></li>
<li><a
href=
"2.4.2-analysis-field.php"
>
2.4.2 Analysis query for a field
</a></li>
</ul>
</ul>
</ul>
<li>
4. Usage modes
</li>
<li>
4. Usage modes
</li>
...
...
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