Building content search and visualization applications using Elasticsearch with Exaptive will feel pretty familiar if you're already an Elasticsearch user. Exaptive provides some added convenience. Whether you have an existing Elasticsearch instance you want to integrate with or use Exaptive's shared instance to get up and running quickly, you can store and retrieve content quickly without the need to write code. Exaptive also makes working with the data returned easier.
Connecting to Elasticsearch
You will need a few key pieces of information to connect to an Elasticsearch instance.
- Server name/IP address: the location of the Elasticsearch instance
- Port: the port number to connect on
- Index: the named index or indices you will be accessing; you usually have one index per application/content store
- Type: the type(s) of content you will be accessing, which is set up during content indexing; this is typically used to distinguish content with different schema/structure
Your Studio comes with a handful of Elasticsearch components for indexing and querying documents. They use the Python Elasticsearch API to connect to and feed or retrieve content.
To search for components, type #elasticsearch in the explore/search page, as shown below:
The Exaptive Elasticsearch components specify a default server name and port that you are welcome to use for non-sensitive, non-production use. There are no guarantees the content will be secure or stored indefinitely. We recommend setting up a dedicated Elasticsearch instance for your production needs. Contact Exaptive if you would like us to manage your infrastructure.
Exaptive's data model complements the document-oriented structure of Elasticsearch. Exaptive sends data around as lists of entities. In Elasticsearch's case, each entity corresponds to a document, and the entity's attributes correspond to various fields in the index. This applies both to adding content (indexing) and retrieving content (searching/querying).
The main difference between raw Elasticsearch results and what Exaptive returns is that Exaptive provides some additional convenience methods to simplify subsequent use of the results. For instance, the Elasticsearch Search Documents component returns a list of results as the root node (without needing to inspect the JSON object) and flattens each result so that fields normally in _source are available at the root level. Metadata, like the total number of results, are available as separate ports.
You should exercise caution in the following ways.
- Limit the total number of results returned at any one time using the start and size parameters.
- Return the least number of fields needed for your visualization needs.
- Do not return full text of documents as a regular field; use the highlight field to dynamically create snippets/teasers based on search terms.