cancel
Showing results for 
Search instead for 
Did you mean: 

Sort by column

filipousiss
Champ in-the-making
Champ in-the-making
Hi,

I'm wondering if it's possible to make a query like in sql where you can order by column with lucene??

SQL

SELECT *
FROM "spacename"
[WHERE "condition"]
ORDER BY "modified" [ASC, DESC]

LUCENE

new Query(Constants.QUERY_LANG_LUCENE, PATH:\"/app:company_home/cm:"+spacename+"//*\ AND (TEXT:" word  ")));   + ORDER By???


Thx in advance
6 REPLIES 6

kevinr
Star Contributor
Star Contributor
Yes it can be performed programatically when executing the lucene search:
http://wiki.alfresco.com/wiki/Search#Queries_That_Sort

        SearchParameters sp = new SearchParameters();
        sp.addStore(getStoreRef());
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery("PATH:\"//.\"");
        sp.addSort("ID", true);
        ResultSet results = null;
        try
        {
            results = serviceRegistry.getSearchService().query(sp);
            for(ResultSetRow row : results)
            {
                NodeRef currentNodeRef = row.getNodeRef();
                …
            }
        }
        finally
        {
            if(results != null)
            {
                results.close();
            }
        }

Thanks,

Kevin

filipousiss
Champ in-the-making
Champ in-the-making
thx kevin for your reply.

I'm using webservices to send queries to the repository…
So I've looked into the functions of the webservices but I didn't found a function that have a paramter of the type SearchParameters.

Am I wrong or just blind Smiley Tongue??

That's what I'm doing now


query=new Query(Constants.QUERY_LANG_LUCENE, PATH:\"/app:company_home/cm:"+spacename+"//*\ AND (TEXT:" word ")));
QueryResult queryResult = repositoryService.query(STORE, query, false);

Thx in advance

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

I dont believe that you can currently pass search parameters using the current web service API.

I would have thought you would have to resolve the parameter values on the client before sending the query to the web service API.

Perhaps this is a feature we should add thou.  Could you add this as a Jira task.  That way you'll be able to track its progress and we'll be able to prioritise it effectively.

Cheers,
Roy

luba_s
Champ in-the-making
Champ in-the-making
Hi,

I dont believe that you can currently pass search parameters using the current web service API.

I would have thought you would have to resolve the parameter values on the client before sending the query to the web service API.

Perhaps this is a feature we should add thou.  Could you add this as a Jira task.  That way you'll be able to track its progress and we'll be able to prioritise it effectively.

Cheers,
Roy

Hello, are there any news about this? I would really appreciate ability to pass search parameters. Thanks

lfuller
Champ in-the-making
Champ in-the-making
I can create a SearchParameters object, set the field and run the query.  My problem is that, thus far, I've been unable to hit upon anyway to determine what the field names are I should pass in.  If I use ID, then I notice that the field is found and the results are sorted differently.  How would one sort by cm:name or cm:description or cm:created?

lfuller
Champ in-the-making
Champ in-the-making
cm:name maps to @{http://www.alfresco.org/model/content/1.0}name
cm:description maps to @{http://www.alfresco.org/model/content/1.0}description

However, I can't seem to figure out a valid field name for the aspect cm:created.

@{http://www.alfresco.org/model/content/1.0}created does not work.  Anyone out there know what does?