eZ Community » Forums » Extensions » eZ Find » Filter: could not work with whitespace
expandshrink

Filter: could not work with whitespace

Filter: could not work with whitespace

Wednesday 30 December 2009 1:42:23 pm - 6 replies

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.

Wednesday 30 December 2009 6:18:30 pm

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 ?

Thursday 31 December 2009 2:19:48 am

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.

Thursday 31 December 2009 10: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...t;&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 blunk.gif Emoticon

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.

Friday 01 January 2010 1:42:49 am

Hey Bertrand

Many thanks, I will try.

Happy New Year.

Best wishes.

Saturday 02 January 2010 1:19:12 pm

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

Modified on Saturday 02 January 2010 1:27:06 pm by Paul Borgermans

Tuesday 05 January 2010 5:15:05 am

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

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from