Exactly. This is one of the problems with our query api. Hopefully we'll
improve/rework it one day. In the meantime, there might be some modules out
there that could help achieving this :)
On Jun 21, 2010, at 7:36, Will Scheidegger wrote:
>
> Answering my own questions:
> It does not seem like the jcr:score is included in the Content objects
> returned from the query anywhere. The jcr:score does not seem to be anywhere
> in the javax.jcr.Node object for the Content object either. But the it is in
> the javax.jcr.query.Row. The BeanShell script below will give you a list of
> the nodes with their jcr:scores. So doing a query on the website repository
> and the same query on the dms and afterwards combining the two result lists
> to one should be feasible although not easy.
>
> -will
>
>
>
> import info.magnolia.cms.core.*;
> import info.magnolia.cms.util.*;
> import info.magnolia.context.*;
> import java.util.*;
> import javax.jcr.*;
> import javax.jcr.query.*;
>
> ctx = MgnlContext.getSystemContext();
> MgnlContext.setInstance(ctx);
> hm = ctx.getHierarchyManager("website");
>
> String queryString =
> "/jcr:root//*...@jcr:primaryType='mgnl:content']//*[jcr:contains(.,
> 'contact')] order by @jcr:score descending";
> Workspace ws = hm.getWorkspace();
> javax.jcr.query.QueryManager qm = ws.getQueryManager();
>
> javax.jcr.query.Query q = qm.createQuery(queryString,
> javax.jcr.query.Query.XPATH);
> javax.jcr.query.QueryResult r = q.execute();
>
> String[] columns = r.getColumnNames();
> print(columns);
>
> NodeIterator nodes = r.getNodes();
> RowIterator rows = r.getRows();
>
> Node currNode;
> Row currRow;
> int i = 1;
> while (nodes.hasNext()) {
> currNode = nodes.next();
> if (rows.hasNext()) {
> currRow = rows.next();
> } else {
> currRow = null;
> }
> if (currRow != null) {
> print("Row " + i + ": " + currNode + "(" +
> currRow.getValue("jcr:score").getString() + ")");
> } else {
> print("Row " + i + ": " + currNode + "(-)");
> }
> i++;
> }
>
>
> On 20.06.2010, at 21:12, Will Scheidegger wrote:
>
>>
>> Dear Magnolians
>>
>> So queries can be ordered by "jcr:score"... but how can I access the
>> jcr:score? According to [1] jcr:score is a ColumnSpecifier, except that it
>> seems the column cannot be accessed, because jcr:score
>> - is not stored in the MetaData of the Content objects returned from the
>> query
>> - is not in the properties of the javax.jcr.Node object associated with the
>> Content object
>>
>> Does this value only exist during query time and does not make it to the
>> returned objects? If so how would you query on two different location or
>> repositories merging the hits ordered by their score? Or to be more precise:
>> How can I query the website and dms at the same time returning the hits in
>> one combined list according to their score?
>>
>> Thanks!
>> -will
>>
>> ----------------------------------------------------------------
>> For list details see
>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>> To unsubscribe, E-mail to: <[email protected]>
>> ----------------------------------------------------------------
>>
>
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------