Forums / Extensions / eZ Find / Filter: could not work with whitespace

Filter: could not work with whitespace

Author Message

Mingxing Chen

Wednesday 30 December 2009 4:42:23 am

Hello all,

I met an intresting issue, and researched the forum, but didn't get the answer.

I set the filter for an attribute, which is the name of folder. Note: there is a whitespace!

{set $search=fetch( ezfind,search,
                        hash( 'query', $search_text,
                              'filter', array( 'folder/name:Mingxing Test') )
                             ))}

Then try to search the text, eg. 'Test'. The process doesn't work well.

But if there is no space between the words which means the name of folder is one word.(e.g Test), it does work.

Anybody can help me?

Thanks very much.

Shinetech is the leader in next generation global application outsourcing. Shinetech combines world class technical skills, recognized expertise in advanced development methodologies and industry experience to deliver results for global enterprises. Shinetech utilizes distributed Agile methods for rapid and precise systems development.
------------------------------------------------------------------------------------------
Blog: http://www.mingxing.me
Email: [email protected]

Bertrand Dunogier

Wednesday 30 December 2009 9:18:30 am

First, is "Mingxing test" the full string you are looking for, or is it partial ?

Then, out of curiosity, could you try url encoding the string, or at least replace the space with %20 ?

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Mingxing Chen

Wednesday 30 December 2009 5:19:48 pm

Hi Bertrand, Thanks for your reply.

First, is "Mingxing test" the full string you are looking for, or is it partial ?

>>"Mingxing Test" is the full string as the folder name.

 

Then, out of curiosity, could you try url encoding the string, or at least replace the space with %20 ?

>> I did try, but failed. would youl like to look at the message below which was got by debug:

'Filter' => 
    <b>array</b>
      0 => string 'folder/name:Mingxing%20Test'
'fq' => 
    <b>array</b>
      0 => string '( ((meta_installation_id_s:e8ba26d71fa1af8d15cbe4c687f17b44 AND (( ( meta_section_id_si:1 OR meta_section_id_si:3 )) OR ( ( meta_contentclass_id_si:4 OR meta_contentclass_id_si:44 OR meta_contentclass_id_si:45 OR meta_contentclass_id_si:48 ))))  ) AND ( meta_language_code_s:eng-AU ) ) AND meta_is_invisible_b:false' <i>(length=315)</i>
      1 => string 'meta_contentclass_id_si:1' <i>(length=25)</i>
      2 => string 'meta_language_code_s:eng-AU' <i>(length=27)</i>
      3 => string '( meta_contentclass_id_si:1 AND attr_name_s:Mingxing%20Test )' <i>(length=62)</i>

If I remove the whitespace, it works well.

And there is an example in the document of ezfind:

Example:

fetch( ezfind, search,
hash( query, 'eZ Systems',
filter, array( 'car/in_stock:1',
'car/make:Alfa Romeo',
'car/model:8C' ) ) )

Returns:
Result with documents containing the words “ez” and “systems”, attribute “car/in_stock” with a value of “1”, the “car/make” attribute with the value “alfa romeo” and the “car/model” attribute with the value “8c”.

Let me know what is your opinion. Many thanks.

Shinetech is the leader in next generation global application outsourcing. Shinetech combines world class technical skills, recognized expertise in advanced development methodologies and industry experience to deliver results for global enterprises. Shinetech utilizes distributed Agile methods for rapid and precise systems development.
------------------------------------------------------------------------------------------
Blog: http://www.mingxing.me
Email: [email protected]

Bertrand Dunogier

Thursday 31 December 2009 1:36:09 am

I am almost sure that the source of your problem is that ezstring attributes are indexed as 'string' by solr, and string fields have different handling.

I don't have a solution right now, and since I'm on holiday, no Solr to test on (and a new year's eve dinner to cook, too). But what you could do is try manually with the solr backoffice and see what happens: go to http://localhost:8983/solr/select?qt=ezpublish&q=<query>&fq=folder/name:<filter> (replace localhost if necessary, depending on where solr is installed, and replace query with the solr query, and filter with Mingxing Test or anything you want to try it on. You will be able to see in XML what Solr returns exactly, and will know if what is failing is solr or ezfind.

You may also want to check the solr daemon output, from the console, to figure out better what is going on.

Further improvements are planned on strings handling, but it CAN be confusing sometimes ;)

Since you do use the full folder name, I'm guessing that it is not entered manually, right ? If it isn't, and comes from a dropdown or something similar, maybe you could change your filter to use the folder's content object ID ? This would work just fine, and would let you keep moving further for now.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Mingxing Chen

Thursday 31 December 2009 4:42:49 pm

Hey Bertrand

Many thanks, I will try.

Happy New Year.

Best wishes.

Shinetech is the leader in next generation global application outsourcing. Shinetech combines world class technical skills, recognized expertise in advanced development methodologies and industry experience to deliver results for global enterprises. Shinetech utilizes distributed Agile methods for rapid and precise systems development.
------------------------------------------------------------------------------------------
Blog: http://www.mingxing.me
Email: [email protected]

Paul Borgermans

Saturday 02 January 2010 4:19:12 am

The folder/name attribute is most probably configured as a simple string.

In eZ Find up to 2.1, these are indexed by default as a literal string including spaces and other characters and the query syntax for filtering should also take that into account.

So for your query to work, you should add quotes around the string used in filtering too as in the example below:

{set $search=fetch( ezfind,search,  
                      hash( 'query', $search_text, 
                            'filter', array( 'folder/name:"Mingxing Test"') ) )}

FYI

  1. From eZ Find 2.2, there will be the posibility to do the analysis and query time differently for searching/filtering and facets/sorting.
  2. There is also a bug in the ezfind code with respect to generated filter expression in the case of multiple terms, this will be corrected too in ez find 2.2

hth

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Mingxing Chen

Monday 04 January 2010 8:15:05 pm

"

So for your query to work, you should add quotes around the string used in filtering too as in the example below:

{set $search=fetch( ezfind,search,  
                      hash( 'query', $search_text, 
                            'filter', array( 'folder/name:"Mingxing Test"') ) )}
"

Hey Paul

Thank you very much, you pointed out the solution! It works.

I am looking forward to ezfind 2.2~~~ 8-)

/Mingxing

Shinetech is the leader in next generation global application outsourcing. Shinetech combines world class technical skills, recognized expertise in advanced development methodologies and industry experience to deliver results for global enterprises. Shinetech utilizes distributed Agile methods for rapid and precise systems development.
------------------------------------------------------------------------------------------
Blog: http://www.mingxing.me
Email: [email protected]