Bladeren bron

debug searcher

stanley-king 7 jaren geleden
bovenliggende
commit
d930973347
4 gewijzigde bestanden met toevoegingen van 14 en 9 verwijderingen
  1. 3 1
      helper/search/searcher.php
  2. 7 6
      helper/search/util.php
  3. 0 1
      helper/user_session/fcode.php
  4. 4 1
      test/TestSearch.php

+ 3 - 1
helper/search/searcher.php

@@ -413,8 +413,10 @@ class searcher
         $ids = $this->get_ids($dict, $words);
 
         $result = [];
-        foreach ($ids as $id) {
+        foreach ($ids as $id)
+        {
             $name = $dict->name($id);
+
             if($name != false) {
                 $result[] = $name;
             }

+ 7 - 6
helper/search/util.php

@@ -34,7 +34,6 @@ class filter
         foreach ($keywords as $ch)
         {
             if(filter::filter_eword($ch)) {
-//                $words[] = $ch;
                 $word .= $ch;
             }
             else
@@ -44,15 +43,17 @@ class filter
                 }
             }
         }
+        foreach ($keywords as $ch)
+        {
+            if(filter::filter_eword($ch)) {
+                $words[] = $ch;
+            }
+        }
+
         if(!empty($word)) {
             $words[] = $word;
         }
 
-
-//        if(count($words) < 1) {
-//            $words = [];
-//        }
-
         foreach ($keywords as $word)
         {
             if(filter::filter_ch($word)) {

+ 0 - 1
helper/user_session/fcode.php

@@ -126,7 +126,6 @@ class fcode
         if(array_key_exists($commonid,$this->mCodes))
         {
             $result = [];
-
             $fcodes = $this->mCodes[$commonid];
             foreach ($fcodes as $item)
             {

+ 4 - 1
test/TestSearch.php

@@ -54,7 +54,10 @@ class TestSearch extends PHPUnit_Framework_TestCase
     {
         $searcher = new search\searcher();
         $searcher->init();
-        $result = $searcher->get_result(array('keyword' => 'BB','order' =>'price','sort' => 'desc','page_no' => 1,'page_size' => 10));
+        for($i = 0; $i < 10; ++$i) {
+            $result = $searcher->get_result(array('keyword' => 'm', 'order' => 'price', 'sort' => 'desc', 'page_no' => 1, 'page_size' => 10));
+            $result = $searcher->get_word('bb');
+        }
 //        $result = $searcher->match_price(array('price' => 9.27,'page_no' => 1,'page_size' => 10));
 //        $x = 100;
     }