Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 57 Next »

Facets and score parameters are used to categorize data based on attributes of an event stream in WSO2 DAS.

Facets

A facet is an attribute of indexed records which is used to classify the records by the attribute value. Facet attributes allow you to carry out a faceted extended search within the defined categories.  There is no data type called FACET in event streams. Any STRING type field, of which you can define the attribute value as a JSON array  can be indexed as a facet.  Facets are defined when the table schema is created during the persisting of event streams

Facets are used in the implementations of the following REST APIs

Facet usage types

Facets are used in the Analytics REST API and Data Explorer in WSO2 DAS.  Different  usage types of facets are described below.

Score parameters

Score parameters are used as function parameters of score functions. You can define only INTEGER, DOUBLE, FLOAT or LONG type fields as score parameters. You can define s core parameters when you persist event stream definitions along with indices.  Score parameters are used in the implementations of the following REST APIs

Score functions

Score functions are used to override the default score of a record which has facet fields. Default score is 1. The default score is used to retrieve the drill down record count and sub categories of a category. If you override the default value, then the score of that record will be the evaluation of the score function. 

Retrieving the record score matching a drill down search

For an example, in  a record which represents a book you can define PRICE and DISCOUNT as score parameters that can be used for the following score function example:  ‘price - discount’ . You need to define these fields as score parameters and index columns when persisting  the event stream as shown below.

defining score parameters when persisting events

Click the  Simulate  option of the event stream to simulate sending events to the created even stream.  

simulate one facet attribute

For an example, consider an event stream with the following two records.

record1 (Book1) : 
	TITLE : Oliver Twist,
	AUTHOR : C.Dickens,
	PUBLISHED_DATE :["1866","08,"03"],
	COUNT : 22,
	PRICE : 30.00,
	DISCOUNT : 10.00

record2 (Book2) :
	TITLE : Great Expectations,
	AUTHOR : C.Dickens,
	PUBLISHED_DATE : ["1826","09,"14"],
	COUNT : 22,
	PRICE : 50.00,
	DISCOUNT : 12.00

Score parameters are useful when you want to use the drill down count API to get the sum of the scores of records.  If you invoke the API to retrieve the drilldown record count without a score function, then the score of each record is 1  (i.e. the default value). Therefore, the API returns the number of records. You can define a score function as “price - discount” as shown in the below REST API request. For more information, see Drilling Down Through Categories via REST API.

POST https://localhost:9443/analytics/drillDownCount
 
{
           "tableName": "BOOKS_STORE",
           "categories": [
                {
                          "fieldName": "AUTHOR",
                            "path" : ["C.Dickens”]

                }
            ],
		   “scoreFunction” : “PRICE - DISCOUNT”
}

Now, the score of each record is the output of the score function.  Therefore, the API returns 58 as the sum of the effective prices after applying the discount.

Retrieving the record score based on specific categories

You can use the REST API to retrieve the score of each record (after applying the score function) based on specific categories as shown below. For more information, see Retrieving the Number of Records Matching the Drill Down Criteria via REST API.

POST https://localhost:9443/analytics/facets
{
        "tableName" : "BOOK_STORE",
        "fieldName" : "PUBLISHED_DATE",
        "categoryPath" : ["1866", "08"],
        "query" : "timestamp : [1213343534535 TO 465464564644]",
        "scoreFunction" : "PRICE-DISCOUNT"
}

The sample out put of the above request is as follows. It denotes the following.

  • Output of the score function of the records with the PUBLISHED_DATE as ["1866", "08", "23"] is 15.
  • Output of the score function of the records with the PUBLISHED_DATE as ["1866", "08", "12"] is 25.
{
    "categoryPath" : ["1866", "08"],
    "categories" : {"23" : 15, "12" : 25}
}
  • No labels