09-07-2018 11:47 AM
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
]
})
09-10-2018 02:53 PM
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"
}
}
}]
}
09-10-2018 08:58 AM
Can you please try with the "TAG:value" format? For example:
(cm:name:"Bob") AND (TAG:someTag)
09-10-2018 09:03 AM
if the tag has multiple terms then you need quotes TAG:"my new tag"
09-10-2018 10:16 AM
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"
}
}
}]
}
09-10-2018 02:53 PM
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"
}
}
}]
}
09-10-2018 03:07 PM
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...
Explore our Alfresco products with the links below. Use labels to filter content by product module.