PageRenderTime 132ms CodeModel.GetById 51ms app.highlight 2ms RepoModel.GetById 78ms app.codeStats 0ms

/lib/Zend/Search/Lucene/Search/Query/Empty.php

https://bitbucket.org/andrewjleavitt/magestudy
PHP | 138 lines | 38 code | 13 blank | 87 comment | 0 complexity | 1c8c3ccdfbcafc92b3410226f148ecef MD5 | raw file
  1<?php
  2/**
  3 * Zend Framework
  4 *
  5 * LICENSE
  6 *
  7 * This source file is subject to the new BSD license that is bundled
  8 * with this package in the file LICENSE.txt.
  9 * It is also available through the world-wide-web at this URL:
 10 * http://framework.zend.com/license/new-bsd
 11 * If you did not receive a copy of the license and are unable to
 12 * obtain it through the world-wide-web, please send an email
 13 * to license@zend.com so we can send you a copy immediately.
 14 *
 15 * @category   Zend
 16 * @package    Zend_Search_Lucene
 17 * @subpackage Search
 18 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 20 * @version    $Id: Empty.php 20096 2010-01-06 02:05:09Z bkarwin $
 21 */
 22
 23
 24/** Zend_Search_Lucene_Search_Query */
 25#require_once 'Zend/Search/Lucene/Search/Query.php';
 26
 27
 28/**
 29 * @category   Zend
 30 * @package    Zend_Search_Lucene
 31 * @subpackage Search
 32 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 33 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 34 */
 35class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Query
 36{
 37    /**
 38     * Re-write query into primitive queries in the context of specified index
 39     *
 40     * @param Zend_Search_Lucene_Interface $index
 41     * @return Zend_Search_Lucene_Search_Query
 42     */
 43    public function rewrite(Zend_Search_Lucene_Interface $index)
 44    {
 45        return $this;
 46    }
 47
 48    /**
 49     * Optimize query in the context of specified index
 50     *
 51     * @param Zend_Search_Lucene_Interface $index
 52     * @return Zend_Search_Lucene_Search_Query
 53     */
 54    public function optimize(Zend_Search_Lucene_Interface $index)
 55    {
 56        // "Empty" query is a primitive query and don't need to be optimized
 57        return $this;
 58    }
 59
 60    /**
 61     * Constructs an appropriate Weight implementation for this query.
 62     *
 63     * @param Zend_Search_Lucene_Interface $reader
 64     * @return Zend_Search_Lucene_Search_Weight
 65     */
 66    public function createWeight(Zend_Search_Lucene_Interface $reader)
 67    {
 68        #require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
 69        return new Zend_Search_Lucene_Search_Weight_Empty();
 70    }
 71
 72    /**
 73     * Execute query in context of index reader
 74     * It also initializes necessary internal structures
 75     *
 76     * @param Zend_Search_Lucene_Interface $reader
 77     * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
 78     */
 79    public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
 80    {
 81        // Do nothing
 82    }
 83
 84    /**
 85     * Get document ids likely matching the query
 86     *
 87     * It's an array with document ids as keys (performance considerations)
 88     *
 89     * @return array
 90     */
 91    public function matchedDocs()
 92    {
 93        return array();
 94    }
 95
 96    /**
 97     * Score specified document
 98     *
 99     * @param integer $docId
100     * @param Zend_Search_Lucene_Interface $reader
101     * @return float
102     */
103    public function score($docId, Zend_Search_Lucene_Interface $reader)
104    {
105        return 0;
106    }
107
108    /**
109     * Return query terms
110     *
111     * @return array
112     */
113    public function getQueryTerms()
114    {
115        return array();
116    }
117
118    /**
119     * Query specific matches highlighting
120     *
121     * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter  Highlighter object (also contains doc for highlighting)
122     */
123    protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
124    {
125        // Do nothing
126    }
127
128    /**
129     * Print a query
130     *
131     * @return string
132     */
133    public function __toString()
134    {
135        return '<EmptyQuery>';
136    }
137}
138