-
Notifications
You must be signed in to change notification settings - Fork 22
Search Data Structure
This document describes the structure of search queries, suggestions, and search results.
Queries, which are created by front-end and sent to back-end, have the following structure:
{
"text": "battery electric",
"view": "LongRangeElectricVehicles",
"collections": ["cars", "trucks"],
"attributes": [
{
"collection": "cars",
"attribute": "range",
"operator": ">",
"value": 500
}
],
"links": [],
"tab": "all",
"sort": {
"price": 1
},
"position": 0,
"limit": 100
}Specifies the view used to display the results. Although view name is shown to users in the UI, view field of a search query contains view ID. This field cannot be combined with any other field.
Contains an array of names of collections where the search will be performed.
Filters specifying conditions that needs to be satisfied by the search results. They should be similar to the MongoDB query selectors.
A string of keywords which will be used in a fulltext search.
An array of IDs of link types that are associated with the returned collections and documents.
The currently selected tab on the search results screen. Possible values are:
- all
- documents
- collections
- views
- links
When the search is performed for the first time, all value is used by default.
Fields that will be used for sorting the search results. The value 1 represents ascending while -1 represents descending order.
A position from which the search results will be returned. All previous results will be skipped. The default value is 0.
The number of search results returned. This field together with position supports simple pagination. The default value is 20.
Search suggestions, which are returned by back-end to suggest the next part of the query, have the following structure:
{
"collections": [
{
"name": "cars",
"icon": "/path/to/cars_icon.png"
},
{
"name": "trucks",
"icon": "/path/to/trucks_icon.png"
}
],
"attributes": [
{
"collection": "cars",
"attribute": "range",
"constraints": ["isNumber", "greaterThan:0"]
}
],
"views": [
{
"name": "electricCars",
"icon": "/path/to/electric_cars_icon.png"
}
],
"linkTypes": [
{
"from": "cars",
"to": "manufacturers",
"role": "madeBy"
}
]
}They do not contain the whole documents or all information about collections but just the necessary information to be shown in the suggestions under the search bar.
Search results, which are created by back-end and sent to front-end, have the following structure:
{
"query": [{}, {}],
"matched": {
"views": [{}, {}],
"collections": [{}, {}],
"documents": [{}, {}],
"links": [{}, {}]
},
"favorite": {
"views": [{}, {}],
"collections": [{}, {}],
"documents": [{}, {}]
},
"recent": {
"views": [{}, {}],
"collections": [{}, {}],
"documents": [{}, {}]
}
}The individual fields contain data only if the given search view or all search results are shown.
The same object which specified the search query. In case of a query containing only the view ID, the result will contain other parameters as well so they can be shown to a user in the search bar.
Lists of all views, collections, documents, and links that match the search query.
The most popular (by some metric) views, collections, and documents. These are only returned if the all tab is shown.
Recently used views, collections, and documents. These are only returned if the all tab is shown.