Return-Path: X-Original-To: apmail-jackrabbit-dev-archive@www.apache.org Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AB5C995D1 for ; Wed, 30 Nov 2011 17:26:01 +0000 (UTC) Received: (qmail 233 invoked by uid 500); 30 Nov 2011 17:26:01 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 198 invoked by uid 500); 30 Nov 2011 17:26:01 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 190 invoked by uid 99); 30 Nov 2011 17:26:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 17:26:01 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 17:26:00 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id F02A4A992C for ; Wed, 30 Nov 2011 17:25:39 +0000 (UTC) Date: Wed, 30 Nov 2011 17:25:39 +0000 (UTC) From: =?utf-8?Q?Michael_D=C3=BCrig_=28Commented=29_=28JIRA=29?= To: dev@jackrabbit.apache.org Message-ID: <686265699.26726.1322673939985.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <10520268.5224.1298993616946.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (JCR-2906) Multivalued property sorted by last/random value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JCR-2906?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D131601= 62#comment-13160162 ]=20 Michael D=C3=BCrig commented on JCR-2906: ------------------------------------ Looks better but ;-)... in the // after case I think the calculation of the= new array size is incorrect. The tests work but that's just bad luck. Instead of=20 int extraOffset =3D index - offset + c.length -1; c =3D Arrays.copyOf(c, c.length + extraOffset); shouldn't that be int newSize =3D index - offset + 1 c =3D Arrays.copyOf(c, newSize); =20 > Multivalued property sorted by last/random value > ------------------------------------------------ > > Key: JCR-2906 > URL: https://issues.apache.org/jira/browse/JCR-2906 > Project: Jackrabbit Content Repository > Issue Type: Improvement > Components: indexing > Affects Versions: 2.2 > Environment: Windows 7, Sun JDK 1.6.0_23 > Reporter: Paul Lysak > Labels: multivalued, sort > Attachments: JCR-2906-SharedFieldCache.patch, JCR-2906-v2.patch, = JCR-2906-v3.patch, JCR-2906-v4.patch, JCR-2906.patch > > > Sorting on multivalued property may produce incorrect result because sort= ing is performed only by last value of multivalued property. > Steps to reproduce: > 1. Create multivalued field in repository. Example from nodetypes file: > onParentVersion=3D"COPY" protected=3D"false" multiple=3D"false"> > 2. Create few records so that all records except one would contain single= value for MyProperty and one record would contain=20 > first value which is greater then of any other record and the second valu= e is somewhere in the middle. Here is an example: > 1st record: "aaaa" > 2nd record: "cccc" > 3rd record: "dddd", "bbbb" > 3. Run some query which sorts Example of XPath query: > //*[...here are some criteria...] order by @MyProperty ascending > The query would return documents in such order: > "aaaa" > "dddd", "bbbb" > "cccc" > which is not expected order (expected same order as they were entered - a= s "aaaa" < "cccc", "cccc" < "dddd") > After some digging I found out that it happens because method=20 > org.apache.jackrabbit.core.query.lucene.SharedFieldCache.getValueIndex > (called from org.apache.jackrabbit.core.query.lucene.SharedFieldSortCompa= rator.SimpleScoreDocComparator constructor) > returns only last Comparable of the document. Here is overwrites previous= value: > retArray[termDocs.doc()] =3D getValue(value, type); > I tried to concatenate comparables (just to check if it would work for my= case): > =09if(retArray[termDocs.doc()] =3D=3D null) { > =09=09retArray[termDocs.doc()] =3D getValue(value, type); > =09} else { > =09=09retArray[termDocs.doc()] =3D > =09=09=09=09retArray[termDocs.doc()] + " " + getValue(value, type); > =09} > But it didn't worked well either - TermEnum returns terms not in the same= order as JackRabbit returns values of multivalued field > (as an example ["qwer", "asdf"] may become ["asdf", "qwer"] ). So, simple= concatenation doesn't help. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira