Forums / Extensions / eZ Find / exclude class "on the fly"

exclude class "on the fly"

Author Message

Nicolas OTTAVI

Monday 05 July 2010 8:06:00 am

Hi,

Is it possible to exclude some classes from the results "on the fly", I mean when the query is made. I have seen a RawFilterList[] in ezfind.ini that could help, but I can not really understand how to use it, and if it make it possible to exclude more than one class.

By the way, the perfect option would be to have a "include" filtering instead of "exclude" ... a little bit like we can do with fetch('content','list|tree' ...)

Thx for your help,

Nico 0

Paul Borgermans

Monday 05 July 2010 10:36:58 am

Hi

"include filtering" is available through the class_id fetch function parameter which takes also arrays

exclude filtering is possible by using a dedicated filter and using the same expression as used in the "hardcoded' ezfind.ini example

{def $results=fetch(ezfind, search, hash('q', '*:*', limit, 10, 
       filter, array('meta_class_identifier_s:[* TO *] -meta_class_identifier_s:folder')))}

hth

Paul

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

Nicolas OTTAVI

Monday 05 July 2010 1:34:49 pm

Thanks Paul,

After posting the question I made a test, and found out that

'filter', array( '-meta_class_identifier_s:(class_to_exclude)') was working ..;

I did not used the meta_class_identifier_s:[* TO *]

Regards,

Nico O

Paul Borgermans

Monday 05 July 2010 1:55:16 pm

That works too in general: as long as a pure negative query is not the only filter query. Safest bet (with the current version of Solr) is to use the [* TO *] expression along the negative query. The next version of solr will allow it in all cases.

Cheers

Paul

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

tofik sahraoui

Sunday 03 July 2011 1:48:34 pm

By the way, there is a typo on the example that comes with the ezfind.ini file. The example that shows how to exclude certain classes from apearing on the searchresult list is missing a 'm' it should be like this:

RawFilterList[]=meta_class_identifier_s:[* TO *] -meta_class_identifier_s:(folder article)

should be this instead:

RawFilterList[]=meta_class_identifier_ms:[* TO *] -meta_class_identifier_ms:(folder article)