Localtab |
---|
title | Searching by an attribute |
---|
| Searching by an attribute Anchor |
---|
| Search by Attribute |
---|
| Search by Attribute |
---|
|
This denotes implementing an attribute of a set of records as a facet. For an example, in a record which represents a book, you can define the AUTHOR field as a facet when you are persisting the event stream as shown below.
Click the Simulate option of the event stream to simulate sending events to the created event stream.
For the attribute which you defined as a facet, you need to send its values as a JSON string array as shown in the example below .
You can use this facet to retrieve the records of the books which are written by a particular author using the Data Explorer as shown in the example below.
You can perform the above search in the Analytics REST API using the following request. For more information, see Drilling Down Through Categories via REST API. Code Block |
---|
| POST https://localhost:9443/analytics/drillDown
{
"tableName": "BOOK_STORE",
"categories": [
{
"fieldName": "AUTHOR",
"path" : ["C.Dickens"]
}
],
"query" : "timestamp : [1243214324532 TO 4654365223]",
"recordStart" : 0,
"recordCount" : 100
} |
|
Localtab |
---|
title | Extracting sub categories |
---|
| Another use of facets is to extract the sub categories of a category. You can retrieve the immediate sub-categories of a given category (which are represented in a JSON array), using the relevant API. The API returns the immediate subcategories of the given category in the corresponding table. For an example, in a record which represents a book, you can define the PUBLISHED_DATE field as a facet when you are persisting the event stream as shown below. Click the Simulate option of the event stream to simulate sending events to the created even stream. Send its values as a JSON string array for the attribute which you defined as a facet as shown in the example below.
e.g., If the above BOOK_STORE table contains the below four records with the corresponding values for PUBLISHED_DATE attribute, the REST API returns the sub categories of ['1926'] , which are '08' , '04' , and the sub categories of ['1926', '08'] , which are '09' and '10' . - Record 1 - PUBLISHED_DATE:
['1926', '08', '09'] - Record 2 - PUBLISHED_DATE:
['1926', '04', '02'] - Record 3 - PUBLISHED_DATE:
['1816', '09', '01'] - Record 4 - PUBLISHED_DATE:
['1926', '08', '10']
You can retrieve PUBLISHED_DATE as a specific category and its sub categories using the Data Explorer as shown below.
You can perform the above search in the Analytics REST API using the following requests. For more information, see Drilling Down Through Categories via REST API. Code Block |
---|
| POST https://localhost:9443/analytics/facets
{
"tableName" : "BOOK_STORE",
"fieldName" : "PUBLISHED_DATE",
"categoryPath" : ["1926"],
"query" : "timestamp : [1213343534535 TO 465464564644]"
} |
Code Block |
---|
| POST https://localhost:9443/analytics/facets
{
"tableName" : "BOOK_STORE",
"fieldName" : "PUBLISHED_DATE",
"categoryPath" : ["1926","08"],
"query" : "timestamp : [1213343534535 TO 465464564644]"
} |
|
Localtab |
---|
title | Performing a drill down search |
---|
| This denotes a hierarchical implementation of a collection of several categories of attributes within one attribute. The values of a set of records, which you can use to classify the records can be indexed as facets. Those fields which are indexed as facets are used to implement faceted search and drill-down. For an example, in a record which represents a book, you can define the PUBLISHED_DATE field as a facet when you are persisting the event stream as shown below.
Click the Simulate option of the event stream to simulate sending events to the created even stream.
For the attribute which you defined as a facet, you need to send its values as a JSON string array as shown in the example below .
You can use a facet to filter the books by the published date as a specific category and published year/month/date as its sub categories using the Data Explorer as shown below. You can perform the above search in the Analytics REST API using the following request. It will return the records which match the drill down search. For more information, see Retrieving Specific Records through a Drill Down Search via REST API. Code Block |
---|
| POST https://localhost:9443/analytics/drillDown
{
"tableName": "BOOK_STORE",
"categories": [
{
"fieldName": "PUBLISHED_DATE",
"path" : ["1866", "05", "03"]
}
],
"query" : "timestamp : [1243214324532 TO 4654365223]",
"recordStart" : 0,
"recordCount" : 100
} |
Note |
---|
In the above example, PUBLISHED_DATE is a facet of which values are defined in a three element JSON array. In this example, "05" is a sub-category of “1866”, and “03” is a sub-category of “05”. This information is useful to perform drill down search operations. If you want to retrieve records of which the PUBLISHED_DATE starts with “1866”, provide only “1866” in a JSON array as the value of the facet in the REST API request. Similarly, if you want to retrieve records of which the PUBLISHED_DATE is “1866/05/ANY_DAY”, provide [“1866”, “05”] as the value of the facet in the REST API request. |
Also you can perform the above search in the Analytics REST API using the following request. It will return the number of records which match the drill down search. For more information, see Retrieving the Number of Records Matching the Drill Down Criteria via REST API. Code Block |
---|
| POST https://localhost:9443/analytics/drillDownCount
{
"tableName": "BOOK_STORE",
"categories": [
{
"fieldName": "PUBLISHED_DATE",
"path" : ["1866", "05", "03"]
}
],
"query" : "timestamp : [1243214324532 TO 4654365223]
"recordStart" : 0,
"recordCount" : 100
} |
|
Localtab |
---|
title | Searching data within a value range |
---|
| Searching data within a value rangeThis denotes using facets to filter data based on a value range of an attribute which is defined as a facet. For an example, in a record which represents a book, you can define the PRICE field as a facet when you are persisting the event stream as shown below. Tip |
---|
Define the field based on which you want to search data as numeric (INTEHERINTEGER, FLOAT etc.), and as an Index Column. |
Click the Simulate option of the event stream to simulate sending events to the created even stream.
You can perform the above search in the Analytics REST API using the following request. For more information, see Retrieving the Event Count of Range Facets. Note |
---|
in this WSO2 DAS version, the Data Explorer does not support performing search operations on range facets. |
Code Block |
---|
| POST https://localhost:9443/analytics/rangecount
{
"tableName": "BOOK_STORE",
"rangeField" : "PRICE",
"ranges" : [
{
"label" : "20USD - 30USD",
"from" : 20,
"to" : 30
},
{
"label" : "30USD - 40USD",
"from" : 30,
"to" : 40
}
],
"query" : "*:*"
} |
|
|