      1: <?php
      2:
      3: /**
      4:  *
      5:  * A standard interface used for describing search engine implementations.
      6:  *
      7:  * @package alpha::util::search
      8:  * @since 1.2.3
      9:  * @author John Collins <dev@alphaframework.org>
     10:  * @version $Id: SearchProviderInterface.inc 1804 2014-07-27 13:51:07Z alphadevx $
     11:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
     12:  * @copyright Copyright (c) 2014, John Collins (founder of Alpha Framework).
     13:  * All rights reserved.
     14:  *
     15:  * <pre>
     16:  * Redistribution and use in source and binary forms, with or
     17:  * without modification, are permitted provided that the
     18:  * following conditions are met:
     19:  *
     20:  * * Redistributions of source code must retain the above
     21:  *   copyright notice, this list of conditions and the
     22:  *   following disclaimer.
     23:  * * Redistributions in binary form must reproduce the above
     24:  *   copyright notice, this list of conditions and the
     25:  *   following disclaimer in the documentation and/or other
     26:  *   materials provided with the distribution.
     27:  * * Neither the name of the Alpha Framework nor the names
     28:  *   of its contributors may be used to endorse or promote
     29:  *   products derived from this software without specific
     30:  *   prior written permission.
     31:  *
     32:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
     33:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
     34:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     35:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     36:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
     37:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     38:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     39:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     40:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     41:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     42:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     43:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     44:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     45:  * </pre>
     46:  *
     47:  */
     48: interface SearchProviderInterface {
     49:     /**
     50:      * The main search function, you should provide the user's search query as-is and pass it to the
     51:      * search engine.  An array of business objects will be returned (ordered by the search engine).
     52:      *
     53:      * @param string $query The search query.
     54:      * @param string $returnType Use this filter to determine that only business objects of a certain class hould be returned (default is to return all classes indexed).
     55:      * @param integer $start Start point for pagination.
     56:      * @param integer $limit The maximum amount to return in the list (for pagination).
     57:      * @return array An array of matching business objects.
     58:      * @since 1.2.3
     59:      */
     60:     public function search($query, $returnType = 'all', $start = 0, $limit = 10);
     61:
     62:     /**
     63:      * Gets a list of documents related to the business objects matching the object provided.  An array
     64:      * of business objects will be returned (ordered by the search engine).
     65:      *
     66:      * @param AlphaDAO $sourceObject The source object for comparison.
     67:      * @param string $returnType Use this filter to determine that only business objects of a certain class hould be returned (default is to return all classes indexed).
     68:      * @param integer $start Start point for pagination.
     69:      * @param integer $limit The maximum amount to return in the list (for pagination).
     70:      * @param string $distinct Related items will only be returned that have distinct values in this named field.
     71:      * @return array An array of related business objects.
     72:      * @since 1.2.3
     73:      */
     74:     public function getRelated(AlphaDAO $sourceObject, $returnType = 'all', $start = 0, $limit = 10, $distinct = '');
     75:
     76:     /**
     77:      * Adds/updates the business object provided to the search engine index.
     78:      *
     79:      * @param AlphaDAO $sourceObject The object to add to the search index. The sourceObject should already be stored in the database.
     80:      * @throws SearchIndexWriteException
     81:      * @since 1.2.3
     82:      */
     83:     public function index(AlphaDAO $sourceObject);
     84:
     85:     /**
     86:      * Deletes the business object provided from the search engine index.
     87:      *
     88:      * @param AlphaDAO $sourceObject The object to delete from the search index.
     89:      * @throws SearchIndexWriteException
     90:      * @since 1.2.3
     91:      */
     92:     public function delete(AlphaDAO $sourceObject);
     93:
     94:     /**
     95:      * Returns the number of matching objects found in the previous search carried out by this provider.
     96:      *
     97:      * @return integer
     98:      * @since 1.2.3
     99:      */
    100:     public function getNumberFound();
    101: }
    102:
    103: ?>