Forums / Extensions / eZ Find / eZ Find using sort_by

eZ Find using sort_by

Author Message

Greg Lakomy

Friday 13 February 2009 9:15:37 am

Hi,

I'm running into some issues with eZ Find. No matter how I construct sort_by, it doesn't sort my search results. I want to sort by one of the attributes (date type) but it doesn't seem to work. I've tried both ezFind 1.0 and 2.0 versions and sort_by doesn't work. Unless, I'm doing something wrong.

ez Find 1

{def $search = fetch( 'content', 'search',
		hash( 'text', $search_text,
			  'offset', $view_parameters.offset,
			  'limit', $page_limit,
			  'section_id', 10,
			  'subtree_array', $search_subtree_array,
			  'class_id', array( '49' ),
			  'class_attribute_id', $search_field,			  
			  'sort_by', array('attribute', true(), 412))  ) )}

ez Fidnd 2.0

{def $search = fetch( ezfind, search, 
				hash( 'query', $search_text,
				 	  'offset', $view_parameters.offset,
				  	  'limit', $page_limit,
					  'section_id', 10,
					  'subtree_array', $search_subtree_array,
					  'class_id', array( '49' ),
					  'class_attribute_id', $search_field,	
					  'sort_by', hash(412, 'asc') ) )}

Thanks,
Greg.

Developer
http://www.duoconsulting.com

Graham Tillotson

Wednesday 18 February 2009 2:35:51 pm

Bumping this one -- anyone out there tried the attribute sort with eZ Find? We've been working on it today, and we can get the syntax to work with the internal search engine but not with eZ Find. Some key questions around this:

** should the fetch syntax for attribute sorting work the same with both the internal search engine and eZ Find?

** should the attribute sort parameters work for both standard fetches and those with keyword filters (when searching)?

Any help on this would be greatly appreciated.

DUO : CONSULTING
Web content management experts
www.duoconsulting.com

Nicolas Pastorino

Thursday 19 February 2009 8:36:00 am

Hello,

Here is the supported syntax for the sort_by parameter :

'sort_by', hash( 'published', 'asc',
                         'folder/name', 'asc' )

Should you want to sort by only one criteria, use the similar :

'sort_by', hash( 'article/title', 'asc' )

Hope it helped.
Please note the the 2.0 stable version of eZFind is out now, including nice new features, and, on a sidenote, bugfixes.
http://ez.no/company/news/ez_systems_releases_apache_solr_based_open_source_enterprise_search_solution_ez_find_2_0

Enjoy !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Graham Tillotson

Friday 20 February 2009 7:54:51 am

Nicolas,

This is excellent -- thank you! We will try the code today. Is this documented anywhere? We used the standard sort syntax, and read through the eZ Find documentation, and we did not see the syntax in your example.

DUO : CONSULTING
Web content management experts
www.duoconsulting.com

Greg Lakomy

Friday 20 February 2009 11:59:46 am

I've tried using that syntex with my install of eZ Find (1.0.0beta2), but still no luck...

Here is my code:

{def $search = fetch( 'content', 'search',
	hash( 'text', $search_text,
		  'sort_by', hash('press_release_page/title', 'asc'),
		  'offset', $view_parameters.offset,
		  'limit', $page_limit,
		  'section_id', 10,
		  'subtree_array', $search_subtree_array,
		  'class_id', array( '49' ),
		  'class_attribute_id', $search_field
		  ) 
	)}

I will try installing new 2.0 next and give you an update...

Developer
http://www.duoconsulting.com

Greg Lakomy

Wednesday 25 February 2009 7:50:15 am

Quick update... I got sort_by working with eZ Find 2.0

Here is my sample:

{def $search = fetch( ezfind, search,
				hash( 'query', $search_text,
				'sort_by', hash('press_release_page/publish_date', desc),
				'offset', $view_parameters.offset,
				'section_id', 10,
				'subtree_array', $search_subtree_array,
				'class_id', array( '49' ),
				'class_attribute_id', $search_field,
				'limit', $page_limit ) ) }

Filters are helpful too:

{def $search = fetch( ezfind, search,
				hash( 'query', $search_text,
				'sort_by', hash('press_release_page/publish_date', desc),
                                'filter', 'press_release_page/country:Japan',
				'offset', $view_parameters.offset,
				'section_id', 10,
				'subtree_array', $search_subtree_array,
				'class_id', array( '49' ),
				'class_attribute_id', $search_field,
				'limit', $page_limit ) ) }

Developer
http://www.duoconsulting.com

Nicolas Pastorino

Tuesday 03 March 2009 1:24:12 am

Hi Greg,

Great to see that you got everything to work !
A small addition to your post, about the power of filters. It has been enhanced in eZ Find 2.0, now supporting any combination of boolean filters. You can get inspiration from http://ez.no/doc/extensions/ez_find. Here is an excerpt :

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]' 
                                 ) 
                          ) 
      ) 

Would you have another piece of feedback on this 2.0 stable release ? Have you pushed it in production yet ?

Thanks and best regards,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Sylvain Gogel

Friday 27 March 2009 4:15:44 am

ezfind, search is pretty kewl but there is two use cases i cannot acheaves:

<b>Use Case 1:</b>

On a multi content class search ; filter by node.published within a range
something like

'filter', array('published:NOW TO NOW/DAY-30DAY')

To get all content published the last 30 days

this synthax does not work

<b>Use Case 2:</b>

Search multiple classes related to a single theme
This is the school case: News 1--->* Theme
I want to fetch all news that are related to a given theme
Somthing like:

'filter', array( '*/themes/node_id:458')

--
http://www.ecedi.fr
Agence Web, Créa/Conseils, Accessibilité
eZPublish, Drupal, Zend, Symfony