cancel
Showing results for 
Search instead for 
Did you mean: 

Search querys problems [SOLVED]

rhakaro
Champ in-the-making
Champ in-the-making
Hi all again!

I have a new problem developing a query search in my Java code.

I´m seeking some contents in alfresco, but it returns to me empty, only with the "Path" property fill.

I´m doing this:

                ………….
                ………….

                Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/app:company_home/cm:my_folder//*\" + @cm\\:name:plantilla*");
         
           // Execute the query
           final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
           QueryResult queryResult = repositoryService.query(STORE, query, false);
          
           // Display the results
           ResultSet results = queryResult.getResultSet();
           ResultSetRow[] rows = results.getRows();
          
           System.out.println("La busqueda da algo asi:");
           if(rows != null){
              for(ResultSetRow row : rows){
                                      for (NamedValue namedValue : row.getColumns()){
                                             if (namedValue.getName().endsWith("path") == true)
                                                        System.out.println(namedValue.getValue());
                                              if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true)
                                                        System.out.println(namedValue.getValue());
                                              else if (namedValue.getName().endsWith(Constants.PROP_NAME) == true){
                                                        System.out.println(namedValue.getValue());
                                             else if (namedValue.getName().endsWith(Constants.PROP_DESCRIPTION) == true){
                                                        System.out.println(namedValue.getValue());
                                              
                                               ………….
                                               ………….
                                               ………….
}

The only result that doesn´t null is the "path" property.

What could be happen??

Thak you very much!
16 REPLIES 16

maqsood
Confirmed Champ
Confirmed Champ
try this @cm\\:name:\"plantilla*\"  or  @\\{http\\://www.alfresco.org/model/content/1.0\\}name:\'plantilla*\"

rhakaro
Champ in-the-making
Champ in-the-making
Hi  maqsood,

It still not running ;(
I see exactly the same results. Doing debug, I can check that only the only "if" that becomes "true" is the next:

if (namedValue.getName().endsWith("path") == true){
…..

The rest of them are false all times. If I inspect the object "NamedValue" during the execution, it only has fill the "path" property:

{http://www.alfresco.org/model/content/1.0}path

Explained otherwise (sorry for my english if it is too bad Smiley Happy), my "rows" only have one property (path).

Thanks for answering, I´m working on it, if I find the solution I will post here. Maybe is a strange problem…

tim-erwin
Champ in-the-making
Champ in-the-making
Hi,

same problem here. We are successfully getting all kinds of stuff out of Alfresco on Linux. However, since 3.2 lucene queries don't return any data besides the path any more. Switched on debug logging for webservice and it confirms (in Utils) that only the path property is created. Interestingly, on another System (Windows) it works as expected. Could this be an OS issue?

Regards
Tim

rhakaro
Champ in-the-making
Champ in-the-making
I´m using Windows as SO, but I think this is not the problem….

jonthomas500
Champ in-the-making
Champ in-the-making
We are also experiencing this problem. We're running the alfresco- 3.2 on Solaris and using the webservice api.
Using the sample code from the developer website -  the query result that's returned has a result set that contains only the path property named value.
Has anyone made any progress with this.
It is a bit of a show stopper to any further development.

Thanks

Jon

tim-erwin
Champ in-the-making
Champ in-the-making
Sorry for the confusion of concerning the OS: the one that works (on Windows) simply is another version: Preview_2

That could be a temporary solution for some: use 3.2_Preview2 instead of 3.2r

I filed a bug for this, please have a look at it and support it so it gets fixed soon: https://issues.alfresco.com/jira/browse/ALFCOM-3660

Cheers,
Tim

maqsood
Confirmed Champ
Confirmed Champ
try this:
Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
String ROOT = "/app:company_home/cm:"+ISO9075.encode("Folder Name");
String path = "PATH:\"/" + ROOT + "//.\" AND TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"";
final List<String> result = new ArrayList<String>();
final Query query = new Query(Constants.QUERY_LANG_LUCENE, path);
Node [] nodes = null;
try {     
nodes = WebServiceFactory.getRepositoryService().get(new Predicate(null,STORE,query));     
} catch (RepositoryFault e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
if (null != nodes){
NamedValue[] props = null;
for (final Node node : nodes) {
   props = node.getProperties();
   for(NamedValue prop : props) {
      if(prop.getName().endsWith(Constants.PROP_NAME) == true) {                   
         result.add(prop.getValue());
   }
}
}
hope it may resolve your problem  Smiley Tongue

rhakaro
Champ in-the-making
Champ in-the-making
Thank you very much maqsood!!!!!!!!!!!

It runs!!! It runs!!! hehe

I don´t know where is the problem with my code, maybe adding "ISO9075.encode" or "TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" it´s all done. I don´t understand where is the problem, but now it is running and returning me all the properties I need.

I thik it´s posible that the problem was in acces to data in this way:

                    String nodeId = row.getNode().getId();
                    ContentResult contentResult = new ContentResult(nodeId);
                   
                    for (NamedValue namedValue : row.getColumns()){
                        if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true){
                                     ………
                        }
                        ……………
                        ……………
                    }

instead of:

                        NamedValue[] props = null;
         for (final Node node : nodes) {
            props = node.getProperties();
            int i = 0;
            for(NamedValue prop : props) {
               if(prop.getName().endsWith(Constants.PROP_NAME) == true) {                  
                  ………..
               }
               ………………
               ………………
            }

Again, thank you a lot!

tim-erwin
Champ in-the-making
Champ in-the-making
The big difference seems to be the web service method: you used query - the same I used, because it seemed to be the one for such kind of queries (http://wiki.alfresco.com/wiki/Repository_Web_Service#query) and it worked. maqsood suggests using get which I usually use for stuff I explicitly want to retrieve via uuid and so on.

What's the difference between get and query? Which one to use when?

Regards,
Tim
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.