solr 排序的限制。
?
?
there are more terms than documents in field "attr_quotes", but it's impossible to sort on tokenized fields
?2010-06-10 16:01:43 [main] [org.apache.solr.core.SolrCore]-[ERROR] java.lang.RuntimeException: there are more terms than documents in field "attr_quotes", 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.lucen
?attr_quotes asc
? 贴下引发异常的代码。由此证明? 分词的field和 多值的field不能排序的。
?
protected Object createValue(IndexReader reader, Entry entryKey) throws IOException { String field = StringHelper.intern(entryKey.field); final int[] retArray = new int[reader.maxDoc()]; String[] mterms = new String[reader.maxDoc()+1]; TermDocs termDocs = reader.termDocs(); TermEnum termEnum = reader.terms (new Term (field)); int t = 0; // current term number // an entry for documents that have no terms in this field // should a document with no terms be at top or bottom? // this puts them at the top - if it is changed, FieldDocSortedHitQueue // needs to change as well. mterms[t++] = null; try { do { Term term = termEnum.term(); if (term==null || term.field() != field) break; // store term text // we expect that there is at most one term per document if (t >= mterms.length) throw new RuntimeException ("there are more terms than " + "documents in field "" + field + "", but it's impossible to sort on " + "tokenized fields"); mterms[t] = term.text(); termDocs.seek (termEnum); while (termDocs.next()) { retArray[termDocs.doc()] = t; } t++; } while (termEnum.next()); } finally { termDocs.close(); termEnum.close(); } if (t == 0) { // if there are no terms, make the term array // have a single null entry mterms = new String[1]; } else if (t < mterms.length) { // if there are less terms than documents, // trim off the dead array space String[] terms = new String[t]; System.arraycopy (mterms, 0, terms, 0, t); mterms = terms; } StringIndex value = new StringIndex (retArray, mterms); return value; } };
?