Hi all,

Analytics facets APIs provide indexing capabilities for hierarchical
categorization of table entries in New analytics data service (Please refer
to "[Architecture] BAM 3.0 REST APIs for AnalyticsDataService / Indexing /
Search" for more information). Using facet APIs, an user can define
multiple categories as indices for a table and later can be used to search
table entries based on categories. These APIs will be generic, so the user
can assign a weight for each category when indexing, combine a mathematical
function to calculate weights,

*Facet Counts*

As an example in log analysis, consider the following
E.g. log-time : 2015/mar/12/ 20:30:23, 2015/jan/16 13:34:76, 2015/jan/11
01:34:76 ( in 3 different log lines)

In the above example the log time can be defined as a hierarchical facet as
"year/month/date". Later if the user wants to get the counts of log entries
by "year/month", API would return

2015/jan  - Count :2
2015/mar  - Count 1

If the user wants to get the total count of log entries by "year", API
would return

2015 - Count :3

If the user wants to get the count of log entries by "year/month/date", API
returns,

2015/jan/11 - Count :1
2015/jan/16 -  Count :1
2015/mar/12 - Count : 1

*Drill-Down capabilities*

Dill down capabilities are provided by Facets APIs. User can drill down
through the facet hierarchy of the index and search table entries. User
also can combine a search query so he can filter out the table entries. As
an example, in above example, User queries for the total count of log lines
in 2015/jan/11 ( he gets 1 as the count) and then he wants to view the
other attributes of the log line ( TID, Component name, log level, ..etc).


*REST APIs for Facets*

Users will be able to use facets API through REST APIs. Users can create
facets indices via the usual Analytics indexing REST APIs and insert
hierarchical category information through Analytics REST APIs, Following
are the updated Analytics REST APIs.

1. Drill-down through a facets hierarchy

/analytics/drilldown or /analytics/drilldown-count

{
   "tableName" :
   "categories" : [{
                          "name" : hierarchy name  e.g. "Publish date"
                          "categoryPath" : [ ], hierarchy as an array e.g.
["2001", "March", "02"]
                          }],
   "language" :  "lucene" or "regex"
   "query"      :  lucene query or regular expression
   "scoreFunction" : Javascript function to define scoring function
   "scoreParams" : [] Array of docvalue fields used as parameters for
scoring function
}


2. Querying for Ranges (Additional to facets)

/analytics/searchrange or /analytics/rangecount

 {
   "tableName" : "sample-table-name",
   "ranges" : [{
            "label":
            "from" :
            "to"    :
            "minInclusive":
            "maxInclusive":
     }],
    "language" :
    "query" :
}


In addition to the existing index types two more are introduced. They are
"FACET" and "SCOREPARAM". FACET is used to define a hierarchical facet
field and SCOREPARAM is used to define scoring parameters for score
function.

*Adding Facet fields and score fields*

*to a table/tables*
Facet fields and score fields need to be defined using indexing APIs.

/analytics/tables/<table-name>/indices

{
  "field" : "STRING",
  "facetField" : "FACET",
  "scoreField" : "SCOREPARAM"
}

Later user can add facet and score fields using POST to,

 /analytics/tables/<table-name>
[
  {
     "values" : {
       "field" : "value",
       "facetField" : {
                                "weight" :
                                "categoryPath : [ ]
          },
        "scoreField" : <numeric-value>
       }
  }
]

or /analytics/records

[
  {
     "tableName" :
     "values" : {
       "field" : "value",
       "facetField" : {
                                "weight" :
                                "categoryPath : [ ]
          },
        "scoreField" : <numeric-value>
       }
  }
]

Feedback and suggestions are appreciated.

-- 
Gimantha Bandara
Software Engineer
WSO2. Inc : http://wso2.com
Mobile : +94714961919
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to