Note
This API has been available since API level 13.
This API has been available since API level 13.
Searches various items (intents) by using keyword.
Unified search service handles various search targets and allows to find it's items.
Note: This service works tightly with the com.webos.service.intent service.
Search Targets
Note: The service has internal database (sqlite3 FTS3) to index items of application and application contents. For plugins, the service generally searches items from the database (DB8) directly.
Configuring Application Contents Search
To search within the contents of an app, you need to:.
Create a mapping JSON file. Check below example.
search.json
{
"items": [{
"path": "/..../....", <------------- intent path (search key = uri + path)
"extra": { ... }, <------------- extra field of intent (optional)
"labels": [ <------------- list of resource key
"Language",
...
]
}, ...]
}
In the appinfo.json file, specify the path of the mapping JSON file and the intentFilters.
appinfo.json
{
"....",
"searchIndex":"search.json", <------------- mapping JSON file
"intentFilters":[
{
"actions":[
"view"
],
"uris":[
"app://$APP_ID$"
]
}
],
"...."
}
resources/ilibmanifest.json : will read '*/strings.json' on 'files' array.
resources/*/strings.json : will load entire key:value into the sqlite3 FTS database.
Since the search API returns the search result as "Intent"s, the app should be able to handle the intent also.
The parameters will come as part of "webOSSystem.launchParams". You can use this to move app page to show the searched content. For example:
var params = JSON.parse(webOSSystem.launchParams);
params.parsedUri.path // <--- what you created on items's path in search.json
params.extra // (optional) items's extra in search.json
Developing plugins
We support the C++ implementation only. Please refer "./plugins/media" as a plugin template first.
To implement yours, add "com.webos.service.unifiedsearch" to DEPENDS of your component recipe file.
And place the result shared object (.so) file on /usr/lib/plugins/unifiedsearch folder.
The unified search core has following classes to implement plugin.
You need to inherit at least 3 classes (bold items), and need to implement virtual functions.
- Plugin workflow
- Implementation steps
- Using LunaClient class to easy LS2 implementation
- About the Async implementation
API level 13
Gets an ordered list of enabled and disabled categories.
None
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
enabled | Required | Object array: category | Indicates the ordered array of enabled categories. |
disabled | Required | Object array: category | Indicates the array of disabled categories. |
Example: Get list of categories
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/getCategories '{ }'
Response:
{
"disabled":[
{
"id":"com.webos.app.avn.settings",
"name":"Enact AVN Settings"
}
],
"enabled":[
{
"id":"mediaindexer.audio",
"name":"Audio Files"
},
{
"id":"sam.apps",
"name":"Applications"
}
],
"returnValue":true
}
API level 13
Searches with keyword and return intents of items.
Note: Returning intent can be implicit or explicit intent and have display property to show this on screen.
Name | Required | Type | Description |
---|---|---|---|
key | Required | String | Indicates the keyword to find items. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
results | Optional | Object array: groupedIntents | Indicates the results that are grouped intents by categories. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the Error Codes section for more details. |
errorCode | Optional | Number | The error code for the failed operation. |
Error Code | Error Text | Error Description |
---|---|---|
101 | The 'key' isn't specified. | The 'key' does not exist in the request payload. |
102 | The 'key' is empty or too short. (needs >= 2 bytes) | Need to type more than 2 bytes on 'key'. |
search
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/search '{"key":"pro"}'
Response:
{
"results":[
{
"items":[
{
"intent":{
"action":"view",
"uri":"app://com.webos.app.avn.settings/Settings/Profiles"
},
"display":{
"title":"Profiles",
"icon":"/usr/palm/applications/com.webos.app.avn.settings/icon.png"
}
}
],
"categoryId":"com.webos.app.avn.settings"
},
{
"items":[
{
"intent":{
"name":"com.webos.app.androidauto"
},
"display":{
"title":"Android Auto Projection",
"icon":"/usr/palm/applications/com.webos.app.androidauto/icon.png"
}
}
],
"categoryId":"sam.apps"
}
],
"returnValue":true
}
API level 13
Allows enabling or disabling of a category and change the order of the category.
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | Specifies the category to be updated. |
enabled | Optional | Boolean | Indicates if the category is enabled. Possible values are:
|
rank | Optional | Number | Indicates the position in which the specific category is returned by the getCategories() API. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "Error Codes" section for details. |
Error Code | Error Text | Error Description |
---|---|---|
201 | The 'id' isn't specified. | The ID is a mandatory parameter. It must be specified. |
202 | Needs to add at least one of 'rank' or 'enabled'. | Updating category means change rank or enable/disable. So, you should add one of them. |
203 | Needs 'rank' if its enabled. | When you 'enable' the category, you should set 'rank' to order. |
204 | Shouldn't insert 'rank' when its disabled. | When it goes disable, the 'rank' is useless. |
205 | Internal database error. | Failed to update the internal database. |
Example: Change rank of a category and verify in the category list
1. Change the rank of a category.
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/updateCategory '{
"id":"com.webos.app.avn.settings",
"rank":1
}'
Response:
{
"returnValue": false
}
2. Get the list of categories.
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/getCategories '{ }'
Response:
{
"disabled":[
],
"enabled":[
{
"id":"com.webos.app.avn.settings",
"name":"Enact AVN Settings"
},
{
"id":"mediaindexer.audio",
"name":"Audio Files"
},
{
"id":"sam.apps",
"name":"Applications"
}
],
"returnValue":true
}
Example: Disable a category and verify in the category list
1. Disable a category.
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/updateCategory '{
"id":"com.webos.app.avn.settings",
"enabled":false
}'
Response:
{
"returnValue": false
}
2. Get the list of categories.
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/getCategories '{}'
Response:
{
"disabled":[
{
"id":"com.webos.app.avn.settings",
"name":"Enact AVN Settings"
}
],
"enabled":[
{
"id":"mediaindexer.audio",
"name":"Audio Files"
},
{
"id":"sam.apps",
"name":"Applications"
}
],
"returnValue":true
}
Example: Enable a category with a rank 2 order and verify in the category list
1. Enable a category with rank 2.
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/updateCategory '{
"id":"com.webos.app.avn.settings",
"enabled":true,
"rank":2
}'
Response:
{
"returnValue": false
}
2. Get a list of categories.
# luna-send -n 1 -f luna://com.webos.service.unifiedsearch/getCategories '{}'
Response:
{
"disabled":[
],
"enabled":[
{
"id":"mediaindexer.audio",
"name":"Audio Files"
},
{
"id":"com.webos.app.avn.settings",
"name":"Enact AVN Settings"
},
{
"id":"sam.apps",
"name":"Applications"
}
],
"returnValue":true
}
Indicates the category information.
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | Indicates the category ID. |
name | Required | String | Indicates the category name to be displayed on the screen. |
Indicates the display information to show on screen.
Name | Required | Type | Description |
---|---|---|---|
title | Required | String | Indicates the title to display on screen. |
icon | Optional | String | Indicates the icon (thumbnail) path to be displayed on the screen. |
Indicates the categorized intents
Name | Required | Type | Description |
---|---|---|---|
categoryId | Optional | String | Indicates the ID of the category. |
items | Optional | Object array: item | Indicates the list of items. |
Contains intent that has 'display' attribute on 'extra' field internally.
Name | Required | Type | Description |
---|---|---|---|
action | Optional | String | Indicates the action name. |
uri | Optional | String | Indicates the uri pattern list. <scheme>://<host>:<port>/<path> |
name | Optional | String | Indicates the handler name (used for explicit intent) |
extra | Optional | Object | Indicates the additional parameter for the handler. |
Contents