PageRenderTime 249ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/www/system/library/Zend/Search/Lucene/Search/Query/Empty.php

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