1
ccrstudioweb
Leave out some words from XOOPS search

Hi all!
Is there any way to omit some words from XOOPS native search?
Example: Someone is looking for Rua Amador Bueno, but I want the system to look for Amador Bueno only.

There are about ten words I want to omit from search, even if people type some of them.

I´m using 3 characters on search.
Thank you in advance!

2
trabis
Re: Leave out some words from XOOPS search
  • 2010/1/19 21:54

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


In search.php line 106
$myts =& MyTextSanitizer::getInstance();
if (
$action != 'showallbyuser') {
    if (
$andor != "exact") {
        
$ignored_queries = array(); // holds kewords that are shorter than allowed minmum length
        
$temp_queries preg_split('/[s,]+/'$query);
        
$ignore = array('rua''avenida');
        foreach (
$temp_queries as $q) {
            
$q trim($q);
            if (
strlen($q) >= $xoopsConfigSearch['keyword_min'] && !in_array(strtolower($q), $ignore)) {
                
$queries[] = $myts->addSlashes($q);
            } else {
                
$ignored_queries[] = $myts->addSlashes($q);
            }
        }
        if (
count($queries) == 0) {
            
redirect_header('search.php'2sprintf(_SR_KEYTOOSHORT$xoopsConfigSearch['keyword_min']));
            exit();
        }
    }


Add the words you need to ignore separated by a colon inside: $ignore = array('rua', 'avenida');

Not tested.

3
ccrstudioweb
Re: Leave out some words from XOOPS search

Thank you Trabis!!!

As I´m using XOOPS 2.0.18.1 I had to change the following 109 line line From:

if (strlen($q) >= $xoopsConfigSearch['keyword_min']) {                 $queries[] = $myts->addSlashes($q);



To


if (strlen($q) >= $xoopsConfigSearch['keyword_min'] && !in_array(strtolower($q), $ignore)) {                 $queries[] = $myts->addSlashes($q);


And it works as I want!!!
Thank you once more!!!

4
ccrstudioweb
Re: Leave out some words from XOOPS search

Hi all,
Talking about -words- in XOOPS search engine, the case:
I have the smartpartner and xdirectory to storage their information in three main coluns: name, address and phone.

The problem: When I search for someone called Sundfield, the search returns me the address Rua Henrique Sundfield. I need only people called Sundfield.

I would like three kinds of search: name, address and phone.
Does someone have a tip where to start?
Thank you in advanced!

5
ccrstudioweb
Re: Leave out some words from XOOPS search

Ok, here we go!
---------------------------------------------------------
I took a look and I get the conclusion that is neccessary make three kinds of search inside each module.

Let´s start by smartpartner:
It´s xoops_version file says:
// Search $modversion['hasSearch'] = 1; 
$modversion['search']['file'] = "include/search.inc.php"
$modversion['search']['func'] = "smartpartner_search";


To get this, I need to edit include/search.inc.php and make include/search2.inc.php and include/search3.inc.php

But how can I call them separetadely if xoops_version calls only one?

----------------------------------------------------------

Other way is to make diferents xoops/search.php

Other ideas?




6
ccrstudioweb
Re: Leave out some words from XOOPS search

As I guess that to achieve what I want is a little difficult, I tried other solution: Implement other search engine on xoops, and after looked for a lot of php+mysql search engine this one fit all may expectations:
http://www.joedolson.com/Search-Engine-in-PHP-MySQL.php

I hope It may help someone!

Login

Who's Online

268 user(s) are online (166 user(s) are browsing Support Forums)


Members: 0


Guests: 268


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits