Hello Gabriel,

Thanks for reaching out on the mailing list and for working with Unomi.

To create a segment you are right you need to setup some conditions on it.
Here is an example of a segment definition:

{
  "metadata": {
    "id": "contacts",
    "name": "Contacts",
    "scope": "systemscope",
    "description": "You can customize the list below by editing the
contacts segment.",
    "readOnly":true
  },
  "condition": {
    "parameterValues": {
      "subConditions": [
        {
          "parameterValues": {
            "propertyName": "properties.email",
            "comparisonOperator": "exists"
          },
          "type": "profilePropertyCondition"
        },
        {
          "parameterValues": {
            "propertyName": "properties.phoneNumber",
            "comparisonOperator": "exists"
          },
          "type": "profilePropertyCondition"
        },
        {
          "parameterValues": {
            "propertyName": "properties.facebookId",
            "comparisonOperator": "exists"
          },
          "type": "profilePropertyCondition"
        },
        {
          "parameterValues": {
            "propertyName": "properties.twitterId",
            "comparisonOperator": "exists"
          },
          "type": "profilePropertyCondition"
        },
        {
          "parameterValues": {
            "propertyName": "properties.linkedInId",
            "comparisonOperator": "exists"
          },
          "type": "profilePropertyCondition"
        }
      ],
      "operator" : "or"
    },
    "type": "booleanCondition"
  }
}


In this example we define a contacts segment that checks if any of the
listed properties exist. We are using two condition types :
profilePropertyCondition and booleanCondition. These condition types are
defined here :

https://github.com/apache/incubator-unomi/blob/master/plugins/baseplugin/src/main/resources/META-INF/cxs/conditions/profilePropertyCondition.json

and here :

https://github.com/apache/incubator-unomi/blob/master/plugins/baseplugin/src/main/resources/META-INF/cxs/conditions/booleanCondition.json

The evaluator if you are curious are actually OSGi service properties
registered using OSGi Blueprint. This makes it possible to develop new
custom condition evaluators if need be (although you can already do a lot
with the built-in ones). Here is the reference to the blueprint file that
registers those evaluators :

https://github.com/apache/incubator-unomi/blob/master/plugins/baseplugin/src/main/resources/OSGI-INF/blueprint/blueprint.xml

I hope this answers your questions.

Best regards,
  Serge...

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 Wed, May 30, 2018 at 9:42 PM, Gabriel Cardoso <
[email protected]> wrote:

> Hello everyone,
> I'm from Globo.com (same team as @diogo.munaro) and we're in the process of
> knowing more about Unomi and its API. Currently we're running in our local
> machines but we're already with some machines ready to deploy Unomi in our
> QA environment.
> I have some questions about the API and I would be really grateful if
> someone could lend me a hand.
> I'm trying to understand the flux to create a segment. Reading the api docs
> (http://unomi.incubator.apache.org/rest-api-doc/index.html) I understood
> that to create a Segment first I need to create a Condition. I see that
> there is a "conditionEvaluator" and a "queryBuilder" as part of the
> payload, but I don't really understand how to use it. Lurking in the github
> repository I found these conditions (
> https://github.com/apache/incubator-unomi/tree/unomi-
> root-1.2.0-incubating/plugins/baseplugin/src/main/java/org/
> apache/unomi/plugins/baseplugin/conditions)
> made as plugins, and also I didn't understand how to use them.
>
> tl;dr:
> How do I create Conditions and how do I create a Segment based on those
> previously created Conditions?
> How do I use those conditions created as plugins as my ConditionType?
>
> Is there any documentation regarding those topics? I would gladly read them
> before asking for help again about those topics.
>
> Thanks in advance,
> --
> Gabriel Cardoso
> Profiling@BigData
> Globo.com
>

Reply via email to