Forums / Extensions / eZ Find / Sort fields

Sort fields

Author Message

Matthieu Sévère

Wednesday 10 March 2010 2:44:28 am

Hello,

is there any way to sort ezfind search by an attribute that is not in the data_map and not classic ones like published, ..

In my case, I search only users and I'd like to sort on "login_count" and "last_visit".

I didn't find any way to do this for now ...

--
eZ certified developer: http://ez.no/certification/verify/346216

Nicolas Pastorino

Wednesday 10 March 2010 5:25:45 am

Hello Matthieu,

The only way to achieve this is to make sure the attributes you want to sort on are indexed. Is this the case for login_count and last_visit ? You can check this by directly requesting the Solr backend, and inspecting what attributes/fields are there : http://localhost:8983/solr/select?q=&qt=ezpublish&fl=*

Then, once they are indexed, the next step is to make sure the given sort field is understood by the query builder in eZ Find. Content attributes and default metadata fields ( "published", "modified",... ) are taken into account. This could be a nice addition to be able to push custom ( metadata ) fields at the class level ( http://issues.ez.no/ezfind :) )

Finally, the field you want to sort needs to be understood by Solr as being a Sortable field. You can verify this based on the field type associated to the attribute you want to sort by, and its definition in schema.xml. Not all filedTypes are sortable.

Let us know how it goes !

--
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

Gaetano Giunta

Wednesday 10 March 2010 5:37:04 am

To add further insight to Nico's helpful explanation:

  • currently it is hard to extend ezfind to add custom indexed/searchable meta-fields on a per-class basis (there are open feature requests open for that)
  • however it is possible to extend ezfind to set up custom handlers that will generate sub-attributes to be indexed for existing attributes
  • thus you can add a 'fake' attribute to your classes, write a subattribute-indexing-handler for it, and let it produce the desired meta-fields to be indexed (login_count, last_visit, etc...)
  • if this is not crystal clear, I can provide an example where we did index the view_count of objects

Principal Consultant International Business
Member of the Community Project Board

Nicolas Pastorino

Wednesday 10 March 2010 6:05:33 am

Good points Gaetano. I could spot this related feature request :
http://issues.ez.no/IssueView.php?Id=15159&activeItem=1

Did you have others in mind ?

Please comment on the issue above to add use cases, per Paul's request. This is a very useful feature imho. Was discussing the same subject this morning on IRC with Bratt & Carlos. It is a hot topic :)

--
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

Matthieu Sévère

Wednesday 10 March 2010 7:13:23 am

@Nicolas : for your first post, the attributes are not indexed ...

@Gaetano :

You mean for example add an handler for the user_account datatype and add new meta-data for login_count ? Sounds nice :)

--
eZ certified developer: http://ez.no/certification/verify/346216

Paul Borgermans

Thursday 11 March 2010 2:04:46 am

As we are in feature freeze now, this won't be added to eZ Find 2.2, sorry

However, similar requests for adding additional meta-data (including custom ones, typically introduced with extensions) have been discussed internally and will most certainly make it in a subsequent release.

Please add your use-cases to the issue tracker, so we can have a comprehensive spec before starting development:

http://issues.ez.no/IssueView.php?Id=15159&activeItem=1

I'll come back soon with specs for this and other new features for eZ Find (like an archive function)

Cheers

Paul

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

Matthieu Sévère

Thursday 11 March 2010 3:17:07 am

Ok Paul,

I added my use-case

--
eZ certified developer: http://ez.no/certification/verify/346216