Forums / Extensions / eZ Find / ezFind 2.2 - sort by name issue

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