eZ Find 2 - excluding attribute from search

Author Message

Greg Lakomy

Friday 27 March 2009 12:10:58 pm

Hi,

Is it possible to exclude an attribute from search? I need to be able to still search that attribute on the admin site but exclude it from the front end.

Greg.

Developer
http://www.duoconsulting.com

Paul Borgermans

Friday 27 March 2009 2:11:31 pm

Not easily for attributes, though you could use the boost functions of eZ Find and add this as parameters in a custom search template.

However, better is to expose this query time functionality as parameters. Can you file an enhancement request?

Thanks
Paul

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

Greg Lakomy

Monday 30 March 2009 8:07:17 am

Enhancement request has been submitted.

Thanks,
Greg

Developer
http://www.duoconsulting.com

Greg Lakomy

Friday 03 April 2009 10:29:50 am

I've implemented temp/dirty solution:

Modified /ezfind/classes/ezfezpsolrquerybuilder.php, buildSearch() function

- below $queryFields added the following code

$queryFields = .......
		
//exclude "internal_tags" attribute from search on the front site
$currentUser = eZUser::currentUser();
$webUser = $currentUser->Login;
if ($webUser == 'anonymous') {
	$key_to_be_deleted = array_search('attr_internal_tags_t', $queryFields);
	$this->array_delete($queryFields,$key_to_be_deleted);
}
eZDebug::writeDebug( $currentUser, 'currentUser' );

- based on the currentUser I can remove key and value from queryFields array

- added array_delete function (from php.net manual)

public function array_delete(&$ary,$key_to_be_deleted)
{
	$new = array();
	if($key_to_be_deleted) {
		if(!array_key_exists($key_to_be_deleted,$ary)) {
			return;
		}
		foreach($ary as $key => $value) {
			if($key != $key_to_be_deleted) {
				$new[$key] = $value;
			}
		}
		$ary = $new;
	}
	if(is_array($key_to_be_deleted)) {
		foreach($key_to_be_deleted as $del) {
			array_delete(&$ary,$del);
		}
	}
	eZDebug::writeDebug( $new, 'array_delete' );
} 

Developer
http://www.duoconsulting.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 19:52:52
Script start
Timing: Jan 30 2025 19:52:52
Module start 'layout'
Timing: Jan 30 2025 19:52:52
Module start 'content'
Timing: Jan 30 2025 19:52:52
Module end 'content'
Timing: Jan 30 2025 19:52:52
Script end

Main resources:

Total runtime0.0210 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 588.2969151.2266
Module start 'layout' 0.00490.0038 739.5234220.7344
Module start 'content' 0.00880.0108 960.25781,003.0391
Module end 'content' 0.01960.0014 1,963.296933.9922
Script end 0.0210  1,997.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002511.9243140.0002
Check MTime0.00104.7327140.0001
Mysql Total
Database connection0.00073.426710.0007
Mysqli_queries0.002713.015930.0009
Looping result0.00000.062410.0000
Template Total0.00104.710.0010
Template load0.00083.660510.0008
Template processing0.00020.984910.0002
Override
Cache load0.00052.559810.0005
General
dbfile0.00031.355980.0000
String conversion0.00000.023840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs