Hello you can find the API for manipulating segments here :

http://unomi.incubator.apache.org/rest-api-doc/index.html#1558745832

Note that you will need to access it through the secure endpoint at
https://localhost:9443/cxs (it works also on the endpoint
http://localhost:8181/cxs but this is due to a bug so it might go away in
the future).

Most of the field should be self explanatory except for the conditions. The
condition is actually a tree of conditions. Here is an example of a segment
definition with a simple condition:

{
  "metadata": {
    "id": "uniqueSegmentId",
    "scope": "exampleScope",
    "enabled": true,
    "name": "Example segment name",
    "description": "Example segment description"
  },
  "condition": {
    "type": "profilePropertyCondition",
    "parameterValues": {
      "propertyName": "properties.nbOfVisits",
      "comparisonOperator": "greaterThan",
      "propertyValueInteger": 3
    }
  }
}

In this example, we create a segment that will incorporate all the profiles
that have the property nbOfVisits greater than 3. The available conditions
are deployed in Unomi using JSON files you can find in the
META-INF/cxs/conditions directory, as in this example:
https://github.com/apache/incubator-unomi/tree/master/plugins/baseplugin/src/main/resources/META-INF/cxs/conditions

The condition system is actually pluggeable, so you could build your own
new conditions or extend existing ones. Each condition JSON defines the
parameters that are available, as well as their type. For example the
booleanCondition.json description boolean conditions that accept
sub-conditions and a boolean operator to combine conditions using a boolean
operator.

Here is an example of a segment that has a boolean condition and
sub-conditions:

{
  "metadata": {
    "id": "_8yux206mc",
    "scope": "exampleScope",
    "enabled": true,
    "name": "booleanSegment",
    "description": "booleanSegmentDescription"
  },
  "condition": {
    "type": "booleanCondition",
    "parameterValues": {
      "operator": "and",
      "subConditions": [
        {
          "type": "profilePropertyCondition",
          "parameterValues": {
            "propertyName": "properties.age",
            "comparisonOperator": "greaterThanOrEqualTo",
            "propertyValueInteger": 18
          }
        },
        {
          "type": "profilePropertyCondition",
          "parameterValues": {
            "propertyName": "properties.gender",
            "comparisonOperator": "equals",
            "propertyValue": "male"
          }
        }
      ]
    }
  }
}

In this example you can see the boolean condition type with the parameter
values using the "and" operator and the sub-conditions. In this case we
build a segment that checks if the profile properties age is greater than
or equal to 18 and the gender is male.

If we look at the booleanCondition.json file available here :
https://github.com/apache/incubator-unomi/blob/master/plugins/baseplugin/src/main/resources/META-INF/cxs/conditions/booleanCondition.json


{
  "metadata": {
    "id": "booleanCondition",
    "name": "booleanCondition",
    "description": "",
    "tags": [
      "logical",
      "profileCondition",
      "eventCondition",
      "sessionCondition",
      "sourceEventCondition"
    ],
    "readOnly": true
  },
  "conditionEvaluator": "booleanConditionEvaluator",
  "queryBuilder": "booleanConditionESQueryBuilder",
  "parameters": [
    {
      "id": "operator",
      "type": "String",
      "multivalued": false,
      "defaultValue": "and"
    },
    {
      "id": "subConditions",
      "type": "Condition",
      "multivalued": true
    }
  ]
}

You can see it defines those two parameters we used. The conditionEvaluator
and queryBuilder properties are references to OSGi service properties
declared in the plugin's Blueprint descriptor file, which you can find here
:
https://github.com/apache/incubator-unomi/blob/master/plugins/baseplugin/src/main/resources/OSGI-INF/blueprint/blueprint.xml

This is only interesting to you if you want to define new conditions, but
you should already be able to do a lot with the built-in conditions as they
may be combined in complex ways to segment the profiles. Please note that
conditions should be kept simple as they do have an impact on performance.

This should get you started (I hope), let me know if you have additional
questions, I'll do my best to answer them.

Best regards,
  Serge Huber.

Serge Huber
CTO & Co-Founder
T +41 22 361 3424
9 route des Jeunes | 1227 Acacias | Switzerland
jahia.com <http://www.jahia.com/>
SKYPE | LINKEDIN <https://www.linkedin.com/in/sergehuber> | TWITTER
<https://twitter.com/sergehuber> | VCARD
<http://www.jahia.com/vcard/HuberSerge.vcf>


> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained and
to discover why Jahia is a leading User Experience Platform (UXP) for
Digital Transformation.

On Tue, Jun 20, 2017 at 11:41 AM, Deepak Malhotra <
[email protected]> wrote:

> Hi Unomi Dev Team,
>
> Me and my team is working on unomi and done capturing part now we want to
> do segmentation,but we are not able to make it
> So,any help from your side on it would be appreciated.
>
> *Thanks and Regards*
>
> *Deepak MalhotraSoftware Developer*
> *P K Online Ventures Pvt. Ltd.*
>

Reply via email to