We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6192
    • 20 Posts
    Dear All,

    When I did a site search in English, I got some results returned. But if I typed traditional chinese characters, then I got nothing returned. What do I have to do to make AjaxSearch snippet to search chinese character contents? Thanks.

    I am using Linux, PHP 5.2.9, MySQL 5.0.81, Apache 2.0

    Here is what listed in the mbstring section of phpinfo()

    mbstring
    Multibyte Support enabled
    Multibyte string engine libmbfl
    Multibyte (japanese) regex support enabled
    Multibyte regex (oniguruma) version 4.4.4
    Multibyte regex (oniguruma) backtrack check On

    mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

    Directive Local Value Master Value
    mbstring.detect_order no value no value
    mbstring.encoding_translation Off Off
    mbstring.func_overload 0 0
    mbstring.http_input pass pass
    mbstring.http_output pass pass
    mbstring.internal_encoding no value no value
    mbstring.language neutral neutral
    mbstring.script_encoding no value no value
    mbstring.strict_detection Off Off
    mbstring.substitute_character no value no value


    Charles
      • 5811
      • 1,717 Posts
      What do I have to do to make AjaxSearch snippet to search chinese character contents?
      If you use an utf-8 encoding, nothing else.
      See this short document with Kanji characters. and try to search something like 情 on this demo page.

      I haven’ tested with traditional chinese characters. But to test the sql order executed by AS with your owns document, substitute the 情 character in the following sql order. Try this sql order with your own database by using phpMyAdmin. And let me know if you get results.

      SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.template, sc.menutitle, sc.content, sc.publishedon, GROUP_CONCAT( DISTINCT CAST(ntv.id AS CHAR) SEPARATOR "," ) AS tv_id, GROUP_CONCAT( DISTINCT ntv.value SEPARATOR ", " ) AS tv_value FROM `mod2_site_content` sc LEFT JOIN( SELECT DISTINCT tv.id, tv.value, tv.contentid FROM `mod2_site_tmplvar_contentvalues` tv WHERE (((tv.value LIKE '%情%'))) ) AS ntv ON sc.id = ntv.contentid WHERE ((sc.id IN (63,308,64,65,66,67,68,69,70,71,72,73,97)) AND (sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.type='document') AND (sc.privateweb=0)) GROUP BY sc.id HAVING (((sc.pagetitle LIKE '%情%') OR (sc.longtitle LIKE '%情%') OR (sc.description LIKE '%情%') OR (sc.alias LIKE '%情%') OR (sc.introtext LIKE '%情%') OR (sc.menutitle LIKE '%情%') OR (sc.content LIKE '%情%') OR (tv_value LIKE '%情%'))) ORDER BY sc.publishedon,sc.pagetitle
      For your information the sql order is catched and displayed on this page as soon as you run a test on the demo site.
        • 6192
        • 20 Posts
        Hi Coroico,

        Yes. We got two rows returned by running the scripts (changed the table nanmes to reflect our modx database).
        But I have one following up question, if we typed 3 or more Chinese characters then AjaxSearch works beautifully. The default search requires 3 or more characters.

        I tried to change default.config.php in /ajaxSearch/configs
        from $dcfg[’minChars’] = 3; to $dcfg[’minChars’] = 1;

        Clear the cache, even restart Apache, but still did not work. What do you have to change to allow only one Japanese character (in our case one or two Chinese characters) ?

          • 5811
          • 1,717 Posts
          Look at this post You need to change the MIN_CHARS too

          Change the line $dcfg[’minChars’] = 3; in the config/default.config.inc.php file (or in your own config file)
          And change the line
          Code:

          define(’MIN_CHARS’,3); // minimum number of characters

          in the classes/search.class.inc.php file.
            • 6192
            • 20 Posts
            Yes. That works! grin By the way, I was wondering can I use the AjaxSearch to search content on my custom tables in Modx? huh Is it going to take some work? Thanks for your quick response.

            Modx Rock!
              • 5811
              • 1,717 Posts
              I was wondering can I use the AjaxSearch to search content on my custom tables in Modx?
              Yes a search in customised tables is possible
              Is it going to take some work?
              It depends. In any case, this require to understand the relational model of your custom tables and the limitation of AjaxSearch.
                • 6192
                • 20 Posts
                Ok. Thanks. Let’s say I want to use AjaxSearch to search customer table customer name where customer is in the state of California, where do I begin to do that?

                I know how to code the sql probably something like
                $sql="select companyname from modx_customers where state = ’CA’ "