Skip to content
pritha-tarento edited this page Feb 25, 2019 · 8 revisions

Native search supports for numeric and string operators.

Operators

String fields

  • contains - String match, contains
  • startsWith - String match, starts with
  • endsWith - String match, ends with
  • notContains - negate of contains
  • notStartsWith- negate of startsWith
  • notEndsWith- negate of endsWith

Also, provided limit & offset with request. limit/offset parameter are optional. Here, offset is the start point (a number) and limit is the number of record return is present

Number/Object fields

  • Default - eq or = - equals
  • neq or != - not equals
  • gte or >= - Greater than or equals
  • gt or > - Greater than
  • lte or <= - Less than or equals
  • lt or < - Less than
  • between or range - values between [min, max] and = min value
  • or - values belongs to [val 1....val n]

Search request payload format

  • root: @type value
  • field: property to filter
  • operator: one of above string or numeric operator as given above.
{
  "id": "open-saber.registry.search",
  "ver": "1.0",
  "ets": "11234",
  "params": {
    "did": "",
    "key": "",
    "msgid": ""
  },
  "request": {
    "root": {
      "field 1": { "operator 1": value 1 },
      "field 2": { "operator 2": value 2 }
    }
  }
}

Sample 1 - Find all Teacher with serialnum as 1

{
  "id": "open-saber.registry.search",
  "ver": "1.0",
  "ets": "11234",
  "params": {
    "did": "",
    "key": "",
    "msgid": ""
  },
  "request": {
    "Teacher": {
      "SerialNum": { "eq": 1 }
    }
  }
}

Sample 2 -Find all Teachers with property serialNum in range [1-2]

{
  "id": "open-saber.registry.search",
  "ver": "1.0",
  "ets": "11234",
  "params": {
    "did": "",
    "key": "",
    "msgid": ""
  },
  "request": {
    "Teacher": {
      "serialNum ": {"range": [1,2]}
    }
  }
}

Sample 3 - Find all Teachers with property teacherName as "Mahir" or "Jash"

{
  "id": "open-saber.registry.search",
  "ver": "1.0",
  "ets": "11234",
  "params": {
    "did": "",
    "key": "",
    "msgid": ""
  }
  "request": {
    "Teacher": {
      "teacherName ": {"or": ["Mahir", "Jash"] }
    }
  }
}  

Sample 4 - Find 10 Teacher nodes index from 2

  • offset is the start point (a number), default value(0) configurable
  • limit is the number of record return is present, default value(100) configurable
{
  "id": "open-saber.registry.search",
  "ver": "1.0",
  "ets": "11234",
  "params": {
    "did": "",
    "key": "",
    "msgid": ""
  },
  "request": {
    "Teacher": {
        // possibly could have some filter too as above samples  
    },
    "limit":10,
    "offset":0
  }
}  
Clone this wiki locally