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:creator:System' }]
};
return defaultQueryBody;
}
}
And in the search-extended.component I have
providers: [
{ provide: SearchConfigurationService, useClass: TestSearchConfigurationService },
SearchService
]
})
Solved! Go 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"
}
}
}]
}
Can you please try with the "TAG:value" format? For example:
(cm:name:"Bob") AND (TAG:someTag)
if the tag has multiple terms then you need quotes TAG:"my new tag"
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"
}
}
}]
}
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"
}
}
}]
}
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...
Discussions, help and advice about the Alfresco Development Framework.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.