ezFind 2.2 - sort by name issue

Author Message

Fabien Mas

Wednesday 30 June 2010 12:59:01 am

Hello, I have just installed ezfind 2.2 and I have this issue : if I sort by name I have an error :

Got invalid result from search engine.<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 </title>
</head>
<body><h2>HTTP ERROR: 500</h2><pre>there are more terms than documents in field "meta_name_t", but it's impossible to sort on tokenized fields

java.lang.RuntimeException: there are more terms than documents in field "meta_name_t", but it's impossible to sort on tokenized fields
 at org.apache.lucene.search.FieldCacheImpl$StringIndexCache.createValue(FieldCacheImpl.java:706)
 at org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:208)
 at org.apache.lucene.search.FieldCacheImpl.getStringIndex(FieldCacheImpl.java:676)
 at org.apache.lucene.search.FieldComparator$StringOrdValComparator.setNextReader(FieldComparator.java:667)
 at org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:94)
 at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:253)
 at org.apache.lucene.search.Searcher.search(Searcher.java:171)
 at org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:988)
 at org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:884)
 at org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:341)
 at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:178)
 at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:195)
 at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
 at org.apache.solr.core.SolrCore.execute(SolrCore.java:1321)
 at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:341)
 at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:244)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
 at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
 at org.mortbay.jetty.Server.handle(Server.java:285)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
 at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:835)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:202)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
 at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:226)
 at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
</pre>
<p>RequestURI=/solr/select</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                

</body>
</html>

If I change and sort by path, it works

Here is my query :

{def $params=hash( 'query', $searchtext,
                             'limit',$limit,
                              'sort_by', hash('name', 'asc'),                              
                              'offset',$offset,
                              'subtree_array', array($node.node_id),
                              'class_id',$classid)}       
{def $resultats=fetch( 'ezfind', 'search',$params)}


Thx, Fabien

Ivo Lukac

Wednesday 30 June 2010 1:23:29 am

Seems like a bug...

And it is: http://issues.ez.no/IssueView.php?Id=15423&activeItem=1

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Fabien Mas

Wednesday 30 June 2010 2:07:38 am

Ok

I have to wait then :)

thanks for your help

Ivo Lukac

Wednesday 30 June 2010 6:20:26 am

You can write a comment on that issue. Then developers will know that more people have that problem and maybe they speed up resolving.

Maybe :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Paul Borgermans

Monday 05 July 2010 11:00:48 am

Indeed,

The default field type for the "name" meta data is "text" which cannot be used to sort (it is split in multiple terms which causes the error you see)

However the following recipe will help you:

You can add a schema definition in schema.xml that does a copyfield from "meta_name_t" to "meta_name_s" (of type string) and use the latter for sorting

So in schema.xml add a new field definition in the <fields> section

 <field name="meta_name_s" type="string" indexed="true" stored="false" />

Then add a copyfield construct:

 <copyField source="meta_name_t" dest="meta_name_s"/>

Finally reindex your site (needed with amost all schema changes) and then modify your fetch functions as follows:

{def $params=hash( 'query', $searchtext,
                             'limit',$limit,
                              'sort_by', hash('meta_name_s', 'asc'),                              
                              'offset',$offset,
                              'subtree_array', array($node.node_id),
                              'class_id',$classid)}       
{def $resultats=fetch( 'ezfind', 'search',$params)}

That should be it

hth

Paul

PS: from eZfind 2.3 it should not be needed to do this as you can already do for regular attributes: specify different field types for search, sort, facet and filter

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

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 29 2025 23:50:00
Script start
Timing: Jan 29 2025 23:50:00
Module start 'layout'
Timing: Jan 29 2025 23:50:00
Module start 'content'
Timing: Jan 29 2025 23:50:00
Module end 'content'
Timing: Jan 29 2025 23:50:00
Script end

Main resources:

Total runtime0.0157 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0038 588.2734151.2266
Module start 'layout' 0.00380.0029 739.500036.6641
Module start 'content' 0.00670.0069 776.164199.3281
Module end 'content' 0.01370.0020 875.492241.9922
Script end 0.0156  917.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002012.4353140.0001
Check MTime0.00095.8974140.0001
Mysql Total
Database connection0.00063.979210.0006
Mysqli_queries0.003220.100830.0011
Looping result0.00000.050110.0000
Template Total0.00149.110.0014
Template load0.00116.900610.0011
Template processing0.00032.171710.0003
Override
Cache load0.00074.525510.0007
General
dbfile0.003019.376980.0004
String conversion0.00000.028840.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.0003 secs