cancel
Showing results for 
Search instead for 
Did you mean: 

Searching for files in a folder by property

stuart_turner
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to call the web services to search a folder to find a file(s) which match a certain criteria.

The property on the file is something like:

Name: {ORS}tenantref Value: 259499

I used the following code to find the folder I need (c#.NET):

    reference = new Reference();
    .store = spacesStore;
    reference.uuid = deptNode.id;

    queryResult = repositoryServiceWSE.queryChildren(reference);

    foreach (ResultSetRow row in queryResult.resultSet.rows)
            {
                // Get the name of the node
                foreach (NamedValue namedValue in row.columns)
                {
                    if (namedValue.name.Contains("name") == true)
                    {
                        if (namedValue.value.Equals(folderName, StringComparison.CurrentCultureIgnoreCase))
                        {



I'm now stuck tring to find the file I want in the folder, I would prefer to do this using a query then looping through all of the files as there may be loads of files.

Can any one provide an example showing how to do this?

Thanks,

Stuart
3 REPLIES 3

gis-olli
Champ in-the-making
Champ in-the-making
I have the same problem. I`m trying to search content via the Web Service API related to a specific property. I have created an own ContentModel with some additional properties. Now i try to search via this properties. If i search only for a some text like:

Query query = new Query(Constants.QUERY_LANG_LUCENE, "TEXT:'anExampleText'");
       
        // Execute the query
        QueryResult queryResult = repositoryService.query(STORE, query, true);

i get the Results e.g.:
row 0: {http://www.alfresco.org/model/content/1.0}PLZ = 26188

This is a property, i added to my Content Model. Now i want to search "backwards" e.g. i want to search the property PLZ.
Can anyone post some code examples?

Thx

gis-olli
Champ in-the-making
Champ in-the-making
Now i solved the Problem. You only have to change the query statement:

Query query1 = new Query(Constants.QUERY_LANG_LUCENE, "+@\\{http\\://www.alfresco.org/model/content/1.0\\}property1:\'value1\" AND (TYPE:\"{http://www.alfresco.org/model/content/1.0}content\")");
       
        // Execute the query
        QueryResult queryResult = repositoryService.query(STORE, query1, true);

stuart_turner
Champ in-the-making
Champ in-the-making
Hi, I solved my issue too by using the following code:

                Query query = new Query();
                query.language = "lucene";  // 2 types "lucene and xpath"
                query.statement = "+PARENT:\"workspace://SpacesStore/" + schema.id + "\"" + "+@ors\\:tenantref:259499";
                result = repositoryServiceWSE.query(spacesStore, query, true);