Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Current »

Orbita uses Elastic Search, a highly scalable, open-source, full-text search analytics engine. The use of Elastic search enhances the Chatbot users' experience by providing quick and accurate results.

How to leverage Elastic search capabilities?

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.

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?

Index the documents

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

Using the Search node, you can query against the data and retrieve the results that match the specified criteria. Refer, Search node

Example

Create a schema with the fields facility name, facility image, address, phone number, location (latitude and longitude), etc.

Sample schema (facilitydata) used in this example is:

{
    "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:

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:

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

Place the below code in the Hospital Names function node:

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:

  File Modified

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/Elasticsearch.mp4

Supporting Documentation

How do I index or re-index the documents?

Search node

Useful Links

http://orbita.ai

Related Content

  • No labels