Author: dr
Date: Fri Feb 15 16:43:41 2008
New Revision: 7388
Log:
- Update with comments, extend a bit.
Modified:
experimental/Search/design/design.txt
Modified: experimental/Search/design/design.txt
==============================================================================
--- experimental/Search/design/design.txt [iso-8859-1] (original)
+++ experimental/Search/design/design.txt [iso-8859-1] Fri Feb 15 16:43:41 2008
@@ -38,6 +38,9 @@
class ezcSearchFindQuery (or one of it's children). This query object is
created by
calling the createFindQuery() method on this class. Besides createFindQuery(),
a method to create a query for deleting indexed documents will be provided too.
+The classes representing documents need to implement an interface though that
+specifies __get_state() and __set_state() - something we forgot for
+PersistentObject.
ezcSearchSessionInstance
@@ -59,21 +62,21 @@
ezcSearchDefinitionManager and used by the backends to both index and find
documents from the search backends. For each document field it stores a
ezcSearchObjectProperty. It also defines a field with which a document
-can be uniquely identified. In future versions it could also group fields for
-easier searching of multiple fields etc.
-
-ezcSearchDocument
------------------
-
-And object that can be indexed with the search index. It is also returned as
-part of the ezcSearchResult.
+can be uniquely identified, as well as a default search field. In future
+versions it could also group fields for easier searching of multiple fields
+etc.
ezcSearchHandler
----------------
The base class that all search backends implement. The handlers now how to
communicate to the backends, generate correct search query strings, and how to
-present results. Handlers can also accept search-backend specific options.
+present results. Handlers can also accept search-backend specific options. For
+the first version only ezcSearchSolrHandler is planned, while later versions
+might also have backends for Google, Yahoo! etc. A backend does not have to
+implement the index(), createDeleteQuery() and delete() methods, as they are
+not available for every handler.
+
ezcSearchSolrHandler
--------------------
@@ -86,8 +89,8 @@
--------------
Implements a fluent language to query the search index. The methods are all
-quite the same as ezcDbQuery. It is inherited by ezcSearchFindQuery and
-ezcSearchDeleteQuery for respectably searching in, or deleting from the search
+quite the same as ezcDbQuery. This class is inherited by ezcSearchFindQuery and
+ezcSearchDeleteQuery for searching in, or deleting from the search
index.
@@ -101,9 +104,73 @@
ezcSearchResult
Provides meta data about the search (time, number of results, etc.) as well
as an array of the found results. Depending on the database backend, the
- array of found documents can be of different classes, but they all inherit
- the ezcSearchDocument class.
+ array of found documents can be of different classes, as the document types
+ could be different.
+Example Usage
+=============
+
+::
+
+ <?php
+ $backend = new ezcSearchSolrHandler( 'localhost', 6983 );
+ $session = new ezcSearchSession(
+ $backend,
+ new ezcSearchDefinitionManager( 'path/to/definitions' )
+ );
+
+ // indexing a document
+ $session->index( $document );
+
+ // finding documents where name = Derick
+ $q = $session->createFindQuery();
+ $q->find( $q->eq( 'name', "Derick" ) );
+ $ret = $session->find( $q );
+
+ // finding documents where any field contains Derick, from row 10 and 7
+ // rows long
+ $q = $session->createFindQuery();
+ $q->find( $q->eq( '*', "Derick" ) );
+ $ret = $session->find( $q )->limit( 7, 10 );
+
+ // finding documents where text contains Derick and Tiger, only
+ // having name as returned field, and order by published date.
+ $q = $session->createFindQuery();
+ $q->select( 'name' )
+ ->find( $q->and(
+ $q->eq( 'text', "Derick" ),
+ $q->eq( 'text', 'Tiger' )
+ )
+ )
+ ->orderBy( 'published' );
+ $ret = $session->find( $q );
+
+ // finding documents where text contains Derick or Tiger
+ $q = $session->createFindQuery();
+ $q->find( $q->in( 'text', array( 'Derick', 'Tiger' ) ) );
+ $ret = $session->find( $q );
+
+ // finding documents containing 'Ramius' published between 2007-01-01 and
+ // 2007-12-31
+ $q = $session->createFindQuery();
+ $q->find( $q->and(
+ $q->eq( 'text', 'Ramius' ),
+ $q->between( 'published',
+ new DateTime( '2007-01-01' ), // DateTime object
+ strtotime( "2007-12-31" ) // timestamp
+ )
+ )
+ );
+ $ret = $session->find( $q );
+
+ // finding documents containing 'plane' and putting facets on the
+ // categories, limiting result set to 8 and facets to 4
+ $q = $session->createFindQuery();
+ $q->find( $q->eq( 'description', 'plane' ) )
+ ->limit( 8 )
+ ->facet( 'category' )->limit( 4 );
+
+ ?>
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components