Upload Your Data
You've signed up to Noematic, and learned to use the API - now it's time to upload your data. While we show how to perform the following actions through the API, you can achieve the same effect using the Noematic dashboard. Use whichever method is preferable.
Creating a database
Noematic holds your domain-specific data in databases, which are stored at the team level. Let's create one.
{ "version": "1.0", "view": "team", "action": "create_database", "data": { "name": "Store Products", "model": "cosmopolitan-v10", "language": "en" }}
Note that the create_database action expects associated data.
- stringnameis the display name for your database.
- stringmodelis the AI model used for this database.
- Use Noematic's cosmopolitan-v10 model for any content.
- Other first- and third-party models to come.
- stringlanguageis the ISO 639-1 code of the primary natural language of the content in your database. This property is only a hint and can be set to null or not included.
{ "data": { "id": "MtjraphUEnYS8esgGgTS12Q7zs4uyBrHw" }}
The response data indicates a globally unique
Creating records
Databases are stores of records. You can think of records as the equivalent of rows in relational databases, or documents in document databases. In Noematic, records take the form of arbitrary JSON.
For this example, suppore you want to add records representing products to our database. We might have data like the following.
{ "sku": "GK-2X9-9R8", "name": "KitchenAid Pasta Roller And Cutter", "description": "One Pasta Roller / Two Pasta Cutters / Cleaning Brush / Chrome Finish", "price": 49.99, "reviews": [ { "author": "Emilio Grimes", "comment": "This pasta roller and cutter makes short work of past-making!", "stars": 5 }, { "author": "Jacklyn Delgado", "comment": "This product is a great way to make fresh pasta from scratch!", "stars": 4 }, { "author": "Jalen Washington", "comment": "This tool is too expensive for what you get.", "stars": 2 } ]}
To add this record to a database, you can use the create_database_record action.
{ "version": "1.0", "view": "team", "action": "create_database_record", "data": { "database": { "id": "MtjraphUEnYS8esgGgTS12Q7zs4uyBrHw" }, "content": { "sku": "GK-2X9-9R8", "name": "KitchenAid Pasta Roller And Cutter", "description": "One Pasta Roller / Two Pasta Cutters / Cleaning Brush / Chrome Finish", "price": 49.99, "reviews": [ { "author": "Emilio Grimes", "comment": "This pasta roller and cutter makes short work of past-making!", "stars": 5 }, { "author": "Jacklyn Delgado", "comment": "This product is a great way to make fresh pasta from scratch!", "stars": 4 }, { "author": "Jalen Washington", "comment": "This tool is too expensive for what you get.", "stars": 2 } ] } }}
As before, create_database_record expects some information about the new record.
- objectdatabaseis the database to hold this record.
- stringidis the globally unique identifier of the selected database.
- objectcontentis the content of the record, in the form of arbitrary JSON.
{ "data": { "id": "CVbhVTRS45vk2dVLiSfHDatSZnoeQLmDe" }}
The response data indicates a globally unique
Creating indexes
You've successfully created a database and uploaded your records, but in this state, your records aren't yet searchable. For that, you must create at least one index. Indexes are used to inform Noematic of the searchable or filterable fields in your records, using dot notation. There are various kinds of indexes. You can analyze natural language text with text indexes, ISO 8601-formatted timestamps with datetime indexes, other text (e.g. IDs, codes, etc) with keyword indexes, numbers with integer and float indexes, and boolean values with boolean indexes.
In the product database example, these are some reasonable choices for indexes:
- The fields name, description and reviews.comment contain natural language text and could therefore benefit from a text index. Note how in the last instance, we have specified a nested object path, regardless of reviews being an array.
- The field sku contains a text-based product identifier and could therefore benefit from a keyword index to allow filtering by sku.
- The field reviews.stars indicates an integer star rating for a given review and could therefore benefit from an integer index to allow filtering products based on their review scores.
- The field price is a (possibly) non-integer number, and could therefore benefit from a float index to allow filtering products by price.
You can use the create_database_index action to create an index for review comments.
{ "version": "1.0", "view": "team", "action": "create_database_index", "data": { "database": { "id": "MtjraphUEnYS8esgGgTS12Q7zs4uyBrHw" }, "type": "text", "name": "Review Comments", "field": "reviews.comment" }}
This action takes the following parameters.
- objectdatabaseis the database to hold this index.
- stringidis the globally unique identifier of the selected database.
- stringtypeis the type of the index, this can be one of the following options:
- Use text for natural language text.
- Use datetime for ISO 8601-formatted timestamps.
- Use keyword for other text that must be matched or filtered exactly, including IDs and codes.
- Use integer for numbers without decimals.
- Use float for numbers with decimals.
- Use boolean for true/false values.
- stringnameis a human-readable name for the index.
- stringfieldis a path to searchable text within record contents, using dot notation.
Next steps
You've created a database, uploaded your domain-specific records, and created indexes to make them searchable. Now find out how to search your data.