cancel
Showing results for 
Search instead for 
Did you mean: 

The efficient way of finding property-values

buurd
Champ in-the-making
Champ in-the-making
Hi

I have a script that finds all values used for a particular property. Consider the following function that recives the resultset from a Lucene query and a name of a property (cm:author for example).


function getPropertyValues(results, property){
    var values = new Array();
    for(var i = 0; i < results.length; i++){
        var content = results[i];
        var value = content.properties[property];
        if(values[value] == null){
            values[value] = value;
        }
    }
    return values;
}

This is a really inefficient way of getting the list of property values that matches the query. Imagine that you have about 100 author that have produced 100 documents each, then you have to iterate through 100 000 nodes to make sure that you have not missed one and it is probably take several seconds.

My question is: What is the efficient way of getting the distinct values that exists for a property?

Thanks in advance
Roland
3 REPLIES 3

buurd
Champ in-the-making
Champ in-the-making
Since I have not got any answers here I have now opened a support-ticket. I'll report back when I have an answer.

buurd
Champ in-the-making
Champ in-the-making
I got some feedback from Redpill on the problem. There are a table in the Alfresco-database that I can query:

select distinct string_value from alf_node_properties where qname_id = ?

Now I just need to figure out how to access the database directly, the alfresco way.

//Roland

andy
Champ on-the-rise
Champ on-the-rise
Hi

The DB is not the way to go … There is no index for the query.

See getTopCategories() in LuceneCategoryServiceImpl which is essentially the same thing.

Andy
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.