Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 (INTEHER, FLOAT etc.), and as an Index Column.

...

defining price field as a facet

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
languagetext
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" : "*:*"
}

...

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.

...

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.

 

Code Block
languagetext
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.

 

Code Block
languagetext
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.
Code Block
languagetext
{
    "categoryPath" : ["1866", "08"],
    "categories" : {"23" : 15, "12" : 25, "24" : 42}
}