eZ Community » Forums » Extensions » eZ Find » Resolved Issue 187041 breaks...
expandshrink

Resolved Issue 187041 breaks example-code using range filters

Resolved Issue 187041 breaks example-code using range filters

Thursday 16 February 2012 4:01:39 pm - 10 replies

http://issues.ez.no/18701 solves an issue with url-encoding special characters in the request sent to the solr backend via URL-Get parameter.

But the changes here https://github.com/ezsystems/ezfind/commit/f454bd61bd179039a753d00ea6bf5009710119ea break the filter-example using ranges in the ezfind documentation here: http://doc.ez.no/Extensions/eZ-Publish-extensions/eZ-Find/eZ-Find-2.6/Customization/Template-fetch-functions#eztoc126514_1_7 .

Take this example-template-code from doc.ez.no:

 fetch( ezfind, search, hash( query, 'eZ Systems', 
           filter, array( 'or',
                               array( 'and',
                                        'article/body:hello',
                                       'article/rating:[1 TO 10]' ),
                             array( 'and',
                                       'article/body:goodbye',
                                       'article/rating:[10 TO 20]' )))

Together with the patched ezf-code this will generate the following URL:

 ... attr_rating_i:\[1+TO+10\] ...

Which will cause this solr-exception:

 ... For input string: "[1"
java.lang.NumberFormatException: For input string: "[1"
 ....

Please encode only characters that are not subject to solr-parsing the url... For example, (  (an opening and closing round bracket) isn't escaped.

Can someone confirm this issue? Jérôme ?
Greets, Christian 

 

 

edit: updated link to doc.ez.no / ezfind 2.6 / filter template function

Modified on Thursday 16 February 2012 4:22:06 pm by Christian Rößler

Thursday 16 February 2012 4:30:38 pm

Hi Christian,

I had the same problem today and my post is here: http://share.ez.no/forums/extensions/ez-find/attribute-filter-on-date#comment73661

For me it's a bug. Currently we are not able to use ranges in filters nor search in ezdate/ezdatetime attributes, as they requiere specific format of data containing "special chars" that are escaped.

Thanks for your post!

Thursday 16 February 2012 4:36:14 pm

As an addition, I can / have verified this false behaviour using plain php code to access solr:

$ezsolr = new eZSolr();
$searchPathIdArray = array();
$searchText = '';
$searchTypes = array();
$params = array(
    // sort_by -> SortBy    
   'SortBy' => ...,
 
    // offset -> SearchOffset
    'SearchOffset' => ...,
 
    // limit -> SearchLimit
    'SearchLimit' => ...,
 
    //'SearchContentClassID' => array( <class ID1>[, <class ID2>]... ),
    //'SearchContentClassID' => <class ID1>,
    //'SearchContentClassID' => array( <class identifier1>[, <class ID2>]... ),
    'SearchContentClassID' => array('article', 'foo', 'bar'),
 
    //'SearchSectionID' => <sectionID>
    'SearchSectionID' => ....
 
    //'SearchSubTreeArray' => array( <node ID1>[, <node ID2>]... ),
    'SearchSubTreeArray' => array(2),
 
    // empty filters, will be filled later on
    'Filter' => array(),
);
 
$params['Filter'][] = array( 'or',
    array(
        'and',
        array( 'product_detail/flow_inlet_from' => '[* TO 100]',
                  'product_detail/flow_inlet_to'   => '[100 TO *]' ),
    ),
    array(
        'and',
        array( 'product_size/flow_inlet_from' => '[* TO 100]',
                  'product_size/volumen_flow'   => '[100 TO *]' ),
    ));
 
// pass the request/params to ezsolr::search(...) and fetch the output
$ezsolrSearchResult = $ezsolr->search( $searchText, $params, $searchTypes);

Thursday 16 February 2012 4:39:25 pm

Hi Christian,

I had the same problem today and my post is here: http://share.ez.no/forums/extensions/ez-find/attribute-filter-on-date#comment73661

For me it's a bug. Currently we are not able to use ranges in filters nor search in ezdate/ezdatetime attributes, as they requiere specific format of data containing "special chars" that are escaped.

Thanks for your post!

Thank you! Did not found your post though...
I'll create a new bugreport, linking to our posts. We'll see what happens.

Thursday 16 February 2012 4:54:38 pm

Issue created:   http://issues.ez.no/19143

Thursday 16 February 2012 5:10:51 pm

A ugly "workaround" which at least "fixes" the range-filtering issue (line ~1797):

extension/ezfind/classes/ezfezpsolrquerybuilder.php
 
      //const CHARS_TO_ESCAPE = '+-&|!(){}[]^"~*?:\\';
     const CHARS_TO_ESCAPE = '+-&|!(){}^"~*?:\\';

Modified on Thursday 16 February 2012 5:12:07 pm by Christian Rößler

Thursday 16 February 2012 6:16:30 pm

A ugly "workaround" which at least "fixes" the range-filtering issue (line ~1797):

extension/ezfind/classes/ezfezpsolrquerybuilder.php
 
      //const CHARS_TO_ESCAPE = '+-&|!(){}[]^"~*?:\\';
     const CHARS_TO_ESCAPE = '+-&|!(){}^"~*?:\\';

I've done exactly this recently, as the upgrade from previous 2011.x builds to 2011.12 broke my filters.

Tuesday 20 March 2012 7:44:32 pm

hi. anyone knows if is there an "official" patch for this? i did exactly as you, but wondering what could happen when 2012.03 appears... 

Wednesday 21 March 2012 11:18:02 am

Quote from Carlos Revillo :

hi. anyone knows if is there an "official" patch for this? i did exactly as you, but wondering what could happen when 2012.03 appears... 

I don't think there's an official patch yet.

My usual workflow when it comes to kernel hacks is to keep the files in the root of the web called "EXTENSION HACKS.txt" and "KERNEL HACKS.txt" so when it comes the time to do the upgrades, I check those files and see if I need to reapply the hacks to the new version.

Thursday 05 April 2012 6:27:58 am

Looks like this has been resolved, by reverting eZ Find to its old behavior. See the history section here:

http://issues.ez.no/IssueView.php?Id=19143

Thanks, eZ Engineering!

Thursday 05 April 2012 9:02:19 am

Quote from Greg McAvoy-Jensen :

Looks like this has been resolved, by reverting eZ Find to its old behavior. See the history section here:

http://issues.ez.no/IssueView.php?Id=19143

Thanks, eZ Engineering!

correct. Just wanted to wait to see by myself. I often found issues to be fixed, but in reality it wasn't or those fixes broke other stuff. I wonder whether ez has unit-tests for such cases?  blunk.gif Emoticon

never mind, glad this has been fixed. Will try at a later time.

Chris

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from