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

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 18 2025 02:46:25
Script start
Timing: Jan 18 2025 02:46:25
Module start 'layout'
Timing: Jan 18 2025 02:46:25
Module start 'content'
Timing: Jan 18 2025 02:46:26
Module end 'content'
Timing: Jan 18 2025 02:46:26
Script end

Main resources:

Total runtime0.5161 sec
Peak memory usage4,096.0000 KB
Database Queries76

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0104 589.2656152.6094
Module start 'layout' 0.01040.0064 741.875039.4141
Module start 'content' 0.01670.4973 781.2891691.1172
Module end 'content' 0.51400.0020 1,472.406320.1875
Script end 0.5161  1,492.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.6732160.0002
Check MTime0.00140.2630160.0001
Mysql Total
Database connection0.00130.245710.0013
Mysqli_queries0.435584.3722760.0057
Looping result0.00120.2233740.0000
Template Total0.471091.320.2355
Template load0.00190.361620.0009
Template processing0.469190.896120.2346
Template load and register function0.00010.020010.0001
states
state_id_array0.00130.261610.0013
state_identifier_array0.00070.144520.0004
Override
Cache load0.00170.3321480.0000
Sytem overhead
Fetch class attribute can translate value0.00060.125240.0002
Fetch class attribute name0.00190.3685110.0002
XML
Image XML parsing0.00210.402840.0005
class_abstraction
Instantiating content class attribute0.00000.0059140.0000
General
dbfile0.00150.2873350.0000
String conversion0.00000.002540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 9

Time used to render debug report: 0.0002 secs