[ic] Search problem when mixing words around.

Greg Hanson greg at perusion.com
Mon Aug 31 16:56:43 UTC 2009

Rick Bragg wrote:
> On Fri, 2009-08-28 at 19:20 +0300, Gert van der Spoel wrote:
>>> -----Original Message-----
>>> From: interchange-users-bounces at icdevgroup.org [mailto:interchange-
>>> users-bounces at icdevgroup.org] On Behalf Of Rick Bragg
>>> Sent: Friday, August 28, 2009 1:26 AM
>>> To: interchange-users at icdevgroup.org
>>> Subject: [ic] Search problem when mixing words around.
>>> Hi,
>>> I have a simple search form that I can't seem to get to work properly.
>>> following is a sample of my simple form:
>>> <form action="[area search]" method=post>
>>> [form-session-id]
>>>  <INPUT TYPE=hidden NAME=mv_coordinate VALUE="1">
>>>  <INPUT TYPE=hidden NAME=mv_searchtype VALUE="db">
>>>  <INPUT MAXLENGTH=30 NAME=mv_searchspec type=text size=15>
>>>  <INPUT TYPE=hidden NAME=mv_search_field VALUE=":description:comment">
>>>  <INPUT TYPE=hidden
>>> 	NAME=mv_column_op
>>> 	VALUE="rm">
>>>  <INPUT TYPE=hidden NAME=mv_substring_match VALUE="1">
>>>  <INPUT TYPE=hidden NAME=mv_all_chars VALUE="1">
>>>  <INPUT TYPE=hidden NAME=mv_exact_match VALUE="0">
>>>  <INPUT TYPE=hidden NAME=mv_matchlimit VALUE="[control matches 25]">
>>>  <INPUT TYPE=hidden NAME=mv_sort_field VALUE="description">
>>>  <input type=submit value="[L]SEARCH[/L]" class="search_button">
>>> </form>
>>> It seems that it is doing substring matches fine. For example, I search
>>> for "icycl" and it finds everything with "bicycle" perfectly.  I can
>>> also search for "fixed gear" or "ixed gea" and it finds everything with
>>> "fixed gear" perfectly.
>>> However, if I search for "gear fixed" it finds nothing and I get an
>>> error...
>>>      Errors:
>>>      Unknown mv_column_op (ARRAY(0x533a890))
>>> So it seems that it can find substring fine, but for some reason it
>>> can't find things where words are rearranged.
>>> Am I doing something wrong, or is this the right behavior?  Is there a
>>> simple way to fix this so that searches for things like "gear fixed"
>>> return rows with "fixed gear" in them?
>>> Thanks!
>>> Rick
>> I copied the above and tested in on my local version and I have not been
>> able to reproduce.
>> http://ic.3edge.com/ic/test2.html  
>> Search for 'rgo rol'  and it will give you 'ergo roller'
>> Search for 'roller ergo' and it will give you 'no matches found' ....
>> The reason that it returns (ARRAY(0x533a890)) is because in
>> lib/Vend/Search.pm at some point you will find:
>> $s->search_error("Unknown mv_column_op (%s)",$o);       (search for
>> 'Unknown' will give you one location).
>> $o is a scalar containing the op ...
>> However sub search_error has:
>>  my ($s, $msg, @args) = @_;
>>  $o ends up in @args ... 
>> That does not seem right to me ... 
>> CU,
>> Gert
> It is expected that a search for "Roller Ergo" will return nothing?

If the contents of the field are "Ergo Roller" and you search for
"Roller Ergo", it will not be found.  Try to write a sql query where
this would work.

Of course if you search for "Roller" or "Ergo" on their own, you will
find the record. 

> Actually, I do want to find "Ergo Roller" when I search for "Roller
> Ergo"  Also a search for "Roller-Ergo" should produce the same results.
> Is there a way to "tokenize" the search spec at all?

You could break down the incoming search terms in perl and use a complex
sql "or" query to "tokenize" the search, but if this is something you
really need to work in an efficient manner, and will have many queries
running, you may want to create a special indexed text field and insert
the potential strings you want to find... ie

code            desc                                ext_search
123            Ergo Roller                       Ergo Roller Roller Ergo
Roller-Ergo Ergonomic Rollers

and use either sub string or a sql query

select * from products where ext_search like '%$searchterm%'

after properly filtering the incoming $searchterm
>   The Array error
> issue may be un-related... 

It is may or may not be related to what you are trying to do, but the
search itself will not work.

> Thanks!
> rick

Greg Hanson
Interchange Consulting
1506 E Gilbert Ave
Coeur d'Alene, ID 83815

Email		greg at perusion.com
Phone		208-214-4306
Toll Free	800-949-1889
Fax		775-256-2231
Web		http://www.perusion.com

Nothing is fool proof to a sufficiently equipped fool

More information about the interchange-users mailing list