Services/SearchService.php
changeset 75 ca2a145e67f3
parent 68 e7384fb35f7a
--- a/Services/SearchService.php	Tue Feb 21 15:15:22 2012 +0100
+++ b/Services/SearchService.php	Thu Feb 23 23:02:07 2012 +0100
@@ -49,12 +49,12 @@
     
     
     /**
+     * Search.
      *
-     * Enter description here ...
      * @param mixed $value : either a string or the list of fields to search into ; format : ['<field_name>' => ['weight'=><relative weight of the field>, 'value' => value]]
      * @param array $conditions : array : key : field name, value : simple value (operator is "=") or array(valuea, value2,...) (operator is IN) or array("operator"=>"=","!=","<".">","<=".">=","like","ilike","in">, "value"=>value)
      * @param array $fields : The field of field names to export, one of the list specified in the configuration file
-     * @return array []
+     * @return array [{'host_doc_id'=>,'wikitag_doc_id'=>, 'wikitag_doc'=>, '_score'=>,'field1'=>, 'field2'=>, }]
      */
     public function search($value, array $conditions = null, array $fields = null)
     {
@@ -145,16 +145,17 @@
     /**
      * List the tag label containing the seed given as an argument.
      * The seed is either at the beggining, the end of the label or at the beggining of a word.
-     * @param unknown_type $seed
-     * @return : an array containing the possible tag labels
+     * @param string $seed
+     * @param boolean $doc_nb
+     * @return : an array containing the possible tag labels with the number of documents
      */
-    public function completion($seed)
+    public function completion($seed, $doc_nb=False)
     {
         $rep = $this->getDoctrine()->getRepository('WikiTagBundle:Tag');
         
         $res = array();
         foreach ($rep->getCompletion($seed) as $value) {
-            $res[] = $value['label'];
+            $res[] = array('label' => $value['label'], 'nb_docs' => $value['nb_docs']);
         }
         
         return $res;