Index

Index proccess for system tables

Now index service is uses one _changes stream for system tables. If rules for one or more tables has changed or added, first of all need fix rules in sys.config and create reindex task for reindexing all docs from 0 sequence. Rules from sys.config will be applied only for new cluster.

Example of task file:

Path: table_files/system_index_task.txt

Body:

[[{table_rules, {user,[{"id",{"test_temp","id",[pk,{varchar,100}]}},
        {"email",{"test_temp","email",[{varchar,100}]}},
        {"phone",{"test_temp","phone",[{varchar,100}]}},
        {"first_name",{"test_temp","first_name",[{varchar,100}]}},
        {"last_name",{"test_temp","last_name",[{varchar,100}]}}]}},
  {temp_table, "test_temp"},
  {table, "users"}],
  [{table_rules,{gtin,[{"id",{"test_temp_gtin","id",[pk,{varchar,100}]}},
        {"owner",{"test_temp_gtin","owner",[{varchar,100}]}},
        {"name",{"test_temp_gtin","name",[text]}},
        {"brand_id",{"test_temp_gtin","brand_id",[{varchar,100}]}}]}},
    {temp_table, "test_temp_gtin"},
    {table, "gtin"}
    ]
  ].

In presented example new process will be indexing table test_temp and test_temp_gtin from 0 sequence. After ends, table test_temp_gtin will be replaced to gtin and test_temp will be replaced to users, task file system_index_task.txt will be deleted and new rules from file will be applied.

Create participant index schema

POST /index-service/index-schema
Parameters
Name Type Description
authenticateit_identity_ticket header Required: Session's ticket
type string index type ("gtin", "slgtin" or "gdti")
fields array::object [{“Made In”:“Made In”, “Other Text Widget Title”:“Name column in web”}]
source_types array::string sources - [“gs1”,“brand”,“expert”,“retailer”,“contributor”]
language string language code in ISO e.g. en, ru
country string country code e.g. 036
Example Response
{
  "conditions": {
    "owner": "urn:authenticateit:participant:1489226097512"
  },
  "created_at": "2017-03-31T12:07:42Z",
  "fields": {
    "field_74f1be4b699c7dd0ad09d09ea7bbea7890029027": {
      "Other Text Widget Title": "Name column in web"
    },
    "field_887c9bb54fa66e8968170597831a48ce56000ccd": {
      "Made In": "Made In"
    }
  },
  "id": "index_schema_gtin_urn:authenticateit:participant:1489226097512",
  "index_type": "gtin",
  "participant_id": "urn:authenticateit:participant:1489226097512",
  "source_types": [
    "gs1",
    "brand"
  ],
  "table": "index_schema_table_gtin_15a4ebb9-eaca-4f02-8329-4415453e6cd5",
  "type": "index_schema",
  "updated_at": "2017-03-31T12:07:42Z",
  "user_id": "urn:authenticateit:user:email:my@gmail.com"
}

Get participant index schema

GET /index-service/index-schema
Parameters
Name Type Description
authenticateit_identity_ticket header Required: Session's ticket
Example Response
[
  {
    "conditions": {
      "owner": "urn:authenticateit:participant:1489226097512"
    },
    "fields": {
      "field_74f1be4b699c7dd0ad09d09ea7bbea7890029027": {
        "Other Text Widget Title": "Name column in web"
      },
      "field_887c9bb54fa66e8968170597831a48ce56000ccd": {
        "Made In": "Made In"
      }
    },
    "id": "index_schema_gtin_urn:authenticateit:participant:1489226097512",
    "source_types": [
      "gs1",
      "brand"
    ],
    "table": "index_schema_table_gtin_15a4ebb9-eaca-4f02-8329-4415453e6cd5",
    "type": "gtin"
  }
]

Request SQL

POST /index-service/rsql/:table
Parameters
Name Type Description
authenticateit_identity_ticket header Required: Session's ticket
query string rsql format
skip - like offset in sql
take - like limit in sql
op - condition OR/AND
include_scans - optional parameter for product table (boolean type: true or false). It is used to count user scans (the parameter “user_scans” is added to the answer)
order - set order, for example: order=id-asc,name-desc
type - set type of request: “data” or “count”
Example rsql
id==123;name==wklnfer
id!=123;name!=wklnfer
| id=le=123;name=le=wklnfer | where id < 123  |
| id=lt=123;name=lt=wklnfer | where id ⇐ 123  |
| id=gt=123;name=gt=wklnfer | where id > 123  |
| id=ge=123;name=gt=wklnfer | where id >= 123 |
id=in=(d9683bd2-fd3e-4b0d-93bb-b58c8c2da284,1,2,3)
id=out=(d9683bd2-fd3e-4b0d-93bb-b58c8c2da284,1,2,3)
id=in=(d9683bd2-fd3e-4b0d-93bb-b58c8c2da284,1,2,3);name==test
id==123;name=like=|wklnfer| for like need set | instead of %
Example Response
{
  "count": 1,
  "data": [
    {
      "id": "04444455368975",
      "image": null,
      "name": "Test product 04444455368975",
      "owner": "urn:authenticateit:participant:1489513906969",
      "sources": null,
      "user_scans": 12
    }
  ]
}

Clear cache

Clear cache for RSQL count requests

POST /index-service/clear_cache
Parameters
Name Type Description
authenticateit_identity_ticket header Required: Session's ticket
date_from string “2017-03-15T15:10:23Z”
date_to string “2017-03-15T15:10:33Z”
Example Response
"Cache successfully deleted"

Request API

POST /index-service/rapi
Parameters
Name Type Description
authenticateit_identity_ticket header Required: Session's ticket
table string table to select e.g. "gtin", "participant" or "brand"
page number page 0,1,2...
limit number limit per page 10,20...
company_prefix string "9300"
Example Response
[
  {
    "id": "09300633912000",
    "name": "Woolworths Select 5 Sectioning Clips Silver",
    "owner": "urn:authenticateit:participant:1486385901460"
  },
  {
    "id": "09300633911959",
    "name": "Woolworths Select 4 Bun Nets Light Brown",
    "owner": "urn:authenticateit:participant:1486385901460"
  }
]

Current system tables

authentication_result
id
event_ts
user_id
code
country
language
latitude
longitude
gtin
id
owner
name
brand_id
index_schema
id
table
participant_id
index_type
user_id
created_at
updated_at
participant
id
name
parent
system
partner
product360
manufacturer
outsource
distributor
retailer
expert
supplier
company_prefix
reward_point_claim
id
rewards_campaign
id
owner
name
products
events
start_date
end_date
users
id
email
language
country
shutout
id
owner
name
products
start_date
end_date
business_location
id
owner
name
longitude
latitude

results matching ""

    No results matching ""