PageRenderTime 33ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/app/sitesearch/lib/Zend/Search/Lucene/Search/Query/Empty.php

https://github.com/cbrunet/sitellite
PHP | 139 lines | 40 code | 14 blank | 85 comment | 0 complexity | d67beeb6189cb4c05a51cba7552d0e7b MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, GPL-3.0, LGPL-2.1
  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-2007 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /** Zend_Search_Lucene_Search_Query */
  22. require_once 'Zend/Search/Lucene/Search/Query.php';
  23. /** Zend_Search_Lucene_Search_Weight_Empty */
  24. require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Search_Lucene
  28. * @subpackage Search
  29. * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Query
  33. {
  34. /**
  35. * Re-write query into primitive queries in the context of specified index
  36. *
  37. * @param Zend_Search_Lucene_Interface $index
  38. * @return Zend_Search_Lucene_Search_Query
  39. */
  40. public function rewrite(Zend_Search_Lucene_Interface $index)
  41. {
  42. return $this;
  43. }
  44. /**
  45. * Optimize query in the context of specified index
  46. *
  47. * @param Zend_Search_Lucene_Interface $index
  48. * @return Zend_Search_Lucene_Search_Query
  49. */
  50. public function optimize(Zend_Search_Lucene_Interface $index)
  51. {
  52. // "Empty" query is a primitive query and don't need to be optimized
  53. return $this;
  54. }
  55. /**
  56. * Constructs an appropriate Weight implementation for this query.
  57. *
  58. * @param Zend_Search_Lucene_Interface $reader
  59. * @return Zend_Search_Lucene_Search_Weight
  60. */
  61. public function createWeight(Zend_Search_Lucene_Interface $reader)
  62. {
  63. return new Zend_Search_Lucene_Search_Weight_Empty();
  64. }
  65. /**
  66. * Execute query in context of index reader
  67. * It also initializes necessary internal structures
  68. *
  69. * @param Zend_Search_Lucene_Interface $reader
  70. */
  71. public function execute(Zend_Search_Lucene_Interface $reader)
  72. {
  73. // Do nothing
  74. }
  75. /**
  76. * Get document ids likely matching the query
  77. *
  78. * It's an array with document ids as keys (performance considerations)
  79. *
  80. * @return array
  81. */
  82. public function matchedDocs()
  83. {
  84. return array();
  85. }
  86. /**
  87. * Score specified document
  88. *
  89. * @param integer $docId
  90. * @param Zend_Search_Lucene_Interface $reader
  91. * @return float
  92. */
  93. public function score($docId, Zend_Search_Lucene_Interface $reader)
  94. {
  95. return 0;
  96. }
  97. /**
  98. * Return query terms
  99. *
  100. * @return array
  101. */
  102. public function getQueryTerms()
  103. {
  104. return array();
  105. }
  106. /**
  107. * Highlight query terms
  108. *
  109. * @param integer &$colorIndex
  110. * @param Zend_Search_Lucene_Document_Html $doc
  111. */
  112. public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
  113. {
  114. // Do nothing
  115. }
  116. /**
  117. * Print a query
  118. *
  119. * @return string
  120. */
  121. public function __toString()
  122. {
  123. return '<EmptyQuery>';
  124. }
  125. }