What Is the Most Basic Data Type in Jina?

//

Angela Bailey

When it comes to working with data in Jina, understanding the basic data types is essential. One of the most fundamental data types in Jina is the Document.

What is a Document?

A Document in Jina represents a unit of data that is processed and manipulated by various components within the Jina ecosystem. It can be any type of content, such as text, image, audio, or video. A Document contains both the raw content and any associated metadata that provides additional information about the content.

Structure of a Document

A Document consists of two main parts:

  1. Data: This refers to the raw content of the document. For example, if the document represents a text file, the data would be the actual text contained within that file.
  2. Metadata: This includes any additional information related to the document. It can include attributes such as title, author, creation date, or any other relevant details.

Create a Document in Jina

To create a Document in Jina, you need to provide both the data and metadata. Here’s an example:


from jina import Document

doc = Document(text='Hello world!', tags={'lang': 'en'})

In this example, we create a new Document with text as “Hello world!” and set its language to English using the ‘lang’ tag.

Data Access and Manipulation

You can access and manipulate both data and metadata in a Document using various methods provided by Jina’s Document API. Some commonly used methods include:

  • doc.text: Returns the raw text content of the document.
  • doc.tags: Returns the metadata associated with the document.update_content(new_content): Updates the data content of the document with new_content.update_tags(new_tags): Updates the metadata of the document with new_tags.

These methods allow you to easily access and modify the content and metadata of a Document as needed during your Jina workflow.

Conclusion

The Document is a fundamental data type in Jina that represents a unit of data, including both raw content and associated metadata. Understanding how to create, access, and manipulate Documents is crucial for building effective Jina workflows. By leveraging the power of Documents, you can efficiently process and organize your data within the Jina ecosystem.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy