Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In Orbita, every document you create will be stored in the Elastic search database. This makes it easier for you to search and retrieve content accurately.

We will describe the steps with he the help of an example of Geo location. In this example, we have facilities and their data stored in a collection of documents.

Schema

A schema enables us to create a collection. The schema is like a skeleton for each document where you fill in the information. To hold this information we need to create a schema. Refer How do I create Schemas?

...

After the schema is created, index the schema. By indexing the schema, any new documents added to the schema are automatically indexed by Elastic search. Refer, https://orbita.atlassian.net/wiki/spaces/OCS/pages/6553674/How+do+I+index+or+re-index+the+documents#Indexing-schemas

Experience Designer

You can make use of the search node is going to search for the queried data against the schema Using the Search node, you can query against the data and retrieve the results that matches match the specified criteria. Refer, Search node

Example

In this example, Create a schema named facilitydataschema is created and every document (facility) created with this schema contains the fields (information) such as facility name, facility image, address, phone number, location (latitude and longitude), etc.

Click on the links below to launch the training and other content.

Sample schema (facilitydata) used in this example is:

Code Block
{
    "fields": [
        {
            "type": "String",
            "fieldType": "text",
            "ref": "",
            "options": [],
            "multiple": false,
            "validation": [
                {
                    "required": false
                }
            ],
            "isDefault": false,
            "label": "Hospital Name",
            "key": "hospitalname"
        },
        {
            "type": "String",
            "fieldType": "text",
            "ref": "",
            "options": [],
            "multiple": false,
            "validation": [
                {
                    "required": false
                }
            ],
            "isDefault": false,
            "label": "City",
            "key": "city"
        },
        {
            "type": "Object",
            "fieldType": "json",
            "ref": "",
            "options": [],
            "multiple": false,
            "validation": [
                {
                    "required": true
                }
            ],
            "isDefault": false,
            "label": "Location Object",
            "key": "location",
            "es": "geo_point"
        }
    ]
}

You can query for any of these fields and get the document and render the information to the chatbot.
For example, if you wanted to know all the hospitals that are available in Davenport city, you can query for the city name and get the results.

The sample document with the above schema is shown below.

...

In the Experience Designer, construct a flow as shown.

...

Place the below code in the City name search function node:

Code Block
queriedCity = msg.payload.request.intent.slots.city_slot.value
msg.payload.q = {
    "query": {
      "bool": {
        "must": {
          "match": {
            "city": queriedCity
          }
        }
      }
    }
  }
return msg;

The Search node configuration is as follows:

...

Code Block
{
    "q" : "{{msg.payload.q}}"
}

Place the below code in the Hospital Names function node:

Code Block
hospitalNameList = "";

hospitalName = msg.payload.search.hits.hits;
node.warn(hospitalName);

var i;
for (i = 0; i < hospitalName.length; i++) {
  hospitalNameList += hospitalName[i]._source.hospitalname + ", ";
}

msg.payload.hospitalNameList = hospitalNameList;
return msg;

The say node configuration is as follows:

...

Export file for the Experience Designer flow:

Attachments
previewfalse
uploadfalse
oldfalse
patterns.*json

In the chatbot, if the chatbot user says Davenport, the Search node will get the hospital names that have the city field as Davenport.

...

Video Content

https://cdn.orbita.cloud/assets/orbita/experiencedesigner/Elasticsearchelasticsearch.mp4

Supporting Documentation

How do I index or re-index the documents?

Search node

Useful Links

http://orbita.ai

Related Content

Page Tree
root3.2 Experience Designer Technical Training