PageRenderTime 34ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/Search/Lucene/Search/Query/Empty.php

https://bitbucket.org/jfrubiom/zendframework-1.x
PHP | 138 lines | 40 code | 13 blank | 85 comment | 0 complexity | e5b82fde7a8c9dddec88dde9f079a776 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-2012 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 24593 2012-01-05 20:35:02Z matthew $
  21. */
  22. /** Zend_Search_Lucene_Search_Query */
  23. require_once 'Zend/Search/Lucene/Search/Query.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Search_Lucene
  27. * @subpackage Search
  28. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Query
  32. {
  33. /**
  34. * Re-write query into primitive queries in the context of specified index
  35. *
  36. * @param Zend_Search_Lucene_Interface $index
  37. * @return Zend_Search_Lucene_Search_Query
  38. */
  39. public function rewrite(Zend_Search_Lucene_Interface $index)
  40. {
  41. return $this;
  42. }
  43. /**
  44. * Optimize query in the context of specified index
  45. *
  46. * @param Zend_Search_Lucene_Interface $index
  47. * @return Zend_Search_Lucene_Search_Query
  48. */
  49. public function optimize(Zend_Search_Lucene_Interface $index)
  50. {
  51. // "Empty" query is a primitive query and don't need to be optimized
  52. return $this;
  53. }
  54. /**
  55. * Constructs an appropriate Weight implementation for this query.
  56. *
  57. * @param Zend_Search_Lucene_Interface $reader
  58. * @return Zend_Search_Lucene_Search_Weight
  59. */
  60. public function createWeight(Zend_Search_Lucene_Interface $reader)
  61. {
  62. require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
  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. * Query specific matches highlighting
  109. *
  110. * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
  111. */
  112. protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
  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. }