PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/mercysam/zfs
PHP | 140 lines | 40 code | 14 blank | 86 comment | 0 complexity | 5d007825d35dac28db62003b05a5ce11 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-2008 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-2008 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. * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
  71. */
  72. public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
  73. {
  74. // Do nothing
  75. }
  76. /**
  77. * Get document ids likely matching the query
  78. *
  79. * It's an array with document ids as keys (performance considerations)
  80. *
  81. * @return array
  82. */
  83. public function matchedDocs()
  84. {
  85. return array();
  86. }
  87. /**
  88. * Score specified document
  89. *
  90. * @param integer $docId
  91. * @param Zend_Search_Lucene_Interface $reader
  92. * @return float
  93. */
  94. public function score($docId, Zend_Search_Lucene_Interface $reader)
  95. {
  96. return 0;
  97. }
  98. /**
  99. * Return query terms
  100. *
  101. * @return array
  102. */
  103. public function getQueryTerms()
  104. {
  105. return array();
  106. }
  107. /**
  108. * Highlight query terms
  109. *
  110. * @param integer &$colorIndex
  111. * @param Zend_Search_Lucene_Document_Html $doc
  112. */
  113. public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
  114. {
  115. // Do nothing
  116. }
  117. /**
  118. * Print a query
  119. *
  120. * @return string
  121. */
  122. public function __toString()
  123. {
  124. return '<EmptyQuery>';
  125. }
  126. }