ADF search query to find nodes by tagNames

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
pedrohernandez
Active Member II

ADF search query to find nodes by tagNames

Jump to solution

Hello, thanks in advance for your help.

So, I've been working on a project base on demo-shell from GitHub - Alfresco/alfresco-ng2-components: Alfresco Angular Components , I need to find nodes on the live-search-bar also by looking by TagsNames. My nodes has tags and already in the share ui i can find them using the tagsname, but in my custom ui I cannot.

I asked this question on Alfresco/alfresco-ng2-components - Gitter , but they told me to come here and ask for help. They told me I have to implement my SearchConfigurationInterface. I have done it but I don't know how to modify it to look for tagsnames. here is my code.

export class TestSearchConfigurationService implements SearchConfigurationInterface {

    constructor() {
    }
    public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody {
        const defaultQueryBody: QueryBody = {
            query: {
                query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
            },
            include: ['path', 'allowableOperations'],
            paging: {
                maxItems: maxResults,
                skipCount: skipCount
            },
            filterQueries: [
                /*tslint:disable-next-line */
                { query: "TYPE:'cm:folder'" },
                { query: 'NOT cm:creatorSmiley Frustratedystem' }]
        };
        return defaultQueryBody;
    }
}

And in the search-extended.component I have    

providers: [
        { provide: SearchConfigurationService, useClass: TestSearchConfigurationService },
        SearchService
    ]
})
1 Solution

Accepted Solutions
pedrohernandez
Active Member II

Re: ADF search query to find nodes by tagNames

Jump to solution

To answer my own question.

Yes it's working now

query: searchTerm ? `${searchTerm}* OR name:${searchTerm}* OR TAG:${searchTerm}*` : searchTerm

this is the correct way for the search query, I was implementing the searchinterface in the wrong place. I Was calling adf-search from search-control.component. I had to put

providers: [
        { provide: SearchConfigurationService, useClass: TestSearchConfigurationService },
        SearchService
    ]

the providers there, I was adding providers to Extended-search component and was not working.

Now I have another question:


How can I add another field for the following query? to search with cm:name OR TAG?
"query": {
    "categories": [
        {
        "id": "queryName",
        "name": "Nombre documento",
        "enabled": true,
        "expanded": true,
        "component": {
            "selector": "adf-search-text",
            "settings": {
                "pattern": "",
                "field": "cm:name",
                "placeholder": "Escriba aqui el texto"
            }
        }
    }]
}
5 Replies
Moderator
Moderator

Re: ADF search query to find nodes by tagNames

Jump to solution

Can you please try with the "TAG:value" format? For example:

(cm:name:"Bob") AND (TAG:someTag)
Moderator
Moderator

Re: ADF search query to find nodes by tagNames

Jump to solution

if the tag has multiple terms then you need quotes TAG:"my new tag"

pedrohernandez
Active Member II

Re: ADF search query to find nodes by tagNames

Jump to solution

Hello, thank you for your answer,

is it possible to have an example?, i don't know to try that out. I tried:

query: searchTerm ? `${searchTerm}* OR name:${searchTerm}* OR TAG:${searchTerm}*` : searchTerm

but it's not working, it just finding nodes by names

While doing the example below on my advanced search, changing the "field" to "TAG". it works ok. it search by TAG. but that's another component not the live search.

"query": {
    "categories": [
        {
        "id": "queryName",
        "name": "Nombre documento",
        "enabled": true,
        "expanded": true,
        "component": {
            "selector": "adf-search-text",
            "settings": {
                "pattern": "",
                "field": "cm:name",
                "placeholder": "Escriba aqui el texto"
            }
        }
    }]
}
pedrohernandez
Active Member II

Re: ADF search query to find nodes by tagNames

Jump to solution

To answer my own question.

Yes it's working now

query: searchTerm ? `${searchTerm}* OR name:${searchTerm}* OR TAG:${searchTerm}*` : searchTerm

this is the correct way for the search query, I was implementing the searchinterface in the wrong place. I Was calling adf-search from search-control.component. I had to put

providers: [
        { provide: SearchConfigurationService, useClass: TestSearchConfigurationService },
        SearchService
    ]

the providers there, I was adding providers to Extended-search component and was not working.

Now I have another question:


How can I add another field for the following query? to search with cm:name OR TAG?
"query": {
    "categories": [
        {
        "id": "queryName",
        "name": "Nombre documento",
        "enabled": true,
        "expanded": true,
        "component": {
            "selector": "adf-search-text",
            "settings": {
                "pattern": "",
                "field": "cm:name",
                "placeholder": "Escriba aqui el texto"
            }
        }
    }]
}
Moderator
Moderator

Re: ADF search query to find nodes by tagNames

Jump to solution

This is a search text widget that works with a single field.

You may want to create your own widget that performs more sophisticated queries. See more details in the following docs: alfresco-ng2-components/search-widget.interface.md at master · Alfresco/alfresco-ng2-components · Gi...