Developer forum

Forum » CMS - Standard features » New index - free text search using String[]

New index - free text search using String[]

Nuno Aguiar
Reply

Hi,

 

We are using a free text parameter but I get 0 results is String array (String[]) even when searching for a single word. If I change it to System.String, it works accurate (but I can no longer search for multiple keywords)

 

Is this the expected behaviour or a bug?

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Høeg Pedersen
Reply

Well, it was not designed for that purpose...

"Product name contains q[]" and q = bicma,cocacol,mayonai should then search for "productname contains bicma* OR productname contains cocacol* OR productname contains mayonai*"

Contains works more like this: q=bicma cocacol mayonai and then that it will do the ord on the fields...

DW uses a TokenStream analyzer to do the job for contains queries - it does that once for the value regardless if it is a string or an array of values.

I have just made a small test where I changed the search to use the analyzer once for each string in the array instead of once on the array and it seems to do what you expect. But you might get some very unexpected results if you do like this:

q=bicma cocacol,mayonai.

You might be able to work around the issue right now by doing like this: q=bicma ,cocacol ,mayonai (adding an extra space)

Anyways, added my change to 8.8.1 next hotfix.

Capture.PNG Capture1.PNG
 
Nicolai Høeg Pedersen
Reply

By the way, my weird search terms is searching for BicMac, CocaCola and Mayonaise :-)

 
Nuno Aguiar
Reply

Hi Nicolai,

 

I actually was having "no results" searching for a single word ("glove", or "bigma" if you prefer smiley) when the parameter was set to a String array. I simply changed the parameter type and hit refresh on the search page and started getting results.

 

I was actually expecting the search to behave like you, meaning:

  • q=bigma cocaco, mayonai
  • searches for bigma cocaco* and also mayonai*

 

BTW: nice search :) I am guessing you were craving for something

 

Does this make sense? I can provide URL and/or screencast if you're curious

 

Best Regards,

Nuno

 
Nicolai Høeg Pedersen
Reply

I already made the change and it is available in the hotfix released today... Try it out.

 
Nuno Aguiar
Reply

Hi Nicolai,

 

Works great, thanks.

Nuno

 

You must be logged in to post in the forum