인공지능

카우치베이스 셸(cbsh) v1.0 출시: 벡터 검색 및 그 이상의 기능 활용하기

정식 출시(GA)를 발표하게 되어 매우 기쁩니다. 카우치베이스 셸 (cbsh), 의 위에 구축된 강력한 명령줄 도구인 누쉘 Couchbase와의 상호작용을 더 쉽고 효율적으로 만들도록 설계되었습니다. Couchbase 쉘은 강력한 기능을 지원합니다. 벡터 검색 기능 이를 통해 애플리케이션이 의미론적으로 유사한 항목을 검색할 수 있도록 함으로써 생성형 AI 애플리케이션의 구동에 사용할 수 있는 벡터 임베딩 다차원 공간에서의 항목 표현. 이번 출시를 통해 cbsh은 벡터 검색 사용자가 명령줄에서 직접 벡터 인덱스를 생성하고 (유사도 검색과 같은) 벡터 검색을 수행할 수 있도록 지원합니다. 이를 통해 사용자는 모델 파라미터 테스트 및 수정, 애드혹(ad hoc) 벡터 쿼리, 간단한 명령줄 인터페이스를 통한 스크립팅 등 다양한 유스케이스를 활용할 수 있습니다.

카우치베이스 셸(Couchbase Shell)은 무엇인가요?

Couchbase Shell은 Couchbase를 사용하는 개발자와 관리자를 위해 맞춤화된 오픈 소스 CLI 도구입니다. 카우치베이스 카펠라 그리고 Couchbase Server. 이 도구를 사용하면 사용자는 쉽게 확장할 수 있는 간단한 명령 라인 도구를 통해 신속하게 모니터링, 쿼리, 데이터 로드, 데이터 내보내기, 전체 벡터 검색을 수행할 수 있으며, 구문 강조, 지능형 자동 완성, 문맥별 도움말, 오류 메시지 등의 최신 기능을 제공합니다.

이 도구는 Couchbase로 사용할 수 있습니다 커뮤니티 지원 프로젝트.

리눅스, 맥, 윈도우 호환 (방문 설치 (전체 목록은 문서 참조).

주요 기능

  • 명령어 파이프라인, 구문 강조 및 자동 완성 기능
  • 연결 관리
  • 데이터 로딩 중
  • 데이터 내보내기
  • 벡터 검색
  • 키-값(KV) 연산 지원
  • SQL++을 사용하여 데이터 쿼리하기

다음은 카우치베이스 셸의 주요 기능 중 일부입니다. 

명령어 파이프라인, 구문 강조 및 자동 완성 기능

누셸(nushell)에서, 파이프라인 Linux 파이프(|)와 유사하게 여러 명령의 조합을 허용합니다. Cbsh은 클러스터와 상호 작용하기 위한 사용자 정의 Couchbase 명령을 추가하여 이를 기반으로 구축됩니다. 또한 사용 중인 셸에 따라 구문 강조를 활성화하고 자동 완성을 제안합니다. 예를 들어, 다음은 기본 nushell 명령을 사용하여 로컬 JSON 파일을 연 다음 테이블로 형식화합니다.

사용하는 셸에 따라 구문 강조(syntax highlighting)가 다를 수 있습니다.

한 번 이런 방식으로 서식화된 결과를 커스텀 cbsh로 파이프할 수 있습니다. 문서 업서트 명령 JSON을 Couchbase 클러스터에 삽입하려면 문서 열기, 포맷팅, 그리고 업서트(upsert)를 수행하는 전체 파이프라인은 다음과 같습니다: 

연결 관리

카우치베이스 셸은 간소화합니다 연결 관리, 최소한의 노력으로 Couchbase에 대한 연결을 설정하고 관리할 수 있습니다. 사용자는 Couchbase에 연결하기 위한 두 가지 옵션이 있습니다.

커맨드 라인 연결 관리 (CLI 인수)

CLI 인수를 통해 Couchbase 셸에 연결하는 것은 간단하며, 명령줄에서 Couchbase 클러스터 작업을 빠르게 시작할 수 있도록 해줍니다. 제공해야 하는 주요 인수는 클러스터 연결 문자열, 사용자 이름, 그리고 비밀번호입니다. 또한 작업하고자 하는 버킷, 특정 스코프 및 컬렉션, 그리고 필요한 경우 인증 메커니즘과 같은 다른 매개변수도 지정할 수 있습니다.

기본 연결 예제

~에게 Couchbase 클러스터에 연결, 다음 명령어를 사용할 수 있습니다:

특정 버킷에 연결하기

Couchbase 클러스터의 버킷에 연결하려면 다음 명령을 사용할 수 있습니다:

설정 파일을 통한 연결

처음 실행할 때 ./cbsh 구성 파일을 생성할 것인지 묻는 프롬프트를 받게 됩니다. “예”를 선택하면 셸에서 기본 클러스터에 대한 정보를 제공하기 위한 일련의 프롬프트를 제공합니다. “아니오”를 선택하면 “Administrator” 사용자 이름과 “password” 비밀번호를 사용하여 localhost에서 실행 중인 로컬 클러스터에 연결을 시도합니다. 구성 파일의 이름은 다음과 같아야 합니다 설정 그리고 에 배치됩니다 .cbsh 홈 디렉토리 또는 셸이 실행 중인 디렉토리에 있는 닷 파일. 더 자세한 내용은 다음에서 확인할 수 있습니다. 문서 사이트.

아래 설정 예제는 두 개의 서로 다른 클러스터(하나는 Capella에, 다른 하나는 로컬 Couchbase 클러스터에)를 정의하는 방법을 보여줍니다. 선택적으로 사용자는 벡터 검색 섹션에서 나중에 설명할 대형 언어 모델(LLM) 설정을 추가할 수도 있습니다.

Loading data

Loading data into Couchbase using Couchbase Shell is a straightforward process that allows you to quickly populate your database with options to load data:

  • Single document JSON files
  • Multiple documents JSON files
  • CSV files
  • Any call to CLI that will output structured text supported by nushell

Users can use 열다 또는 에서 command to first load data into Couchbase Shell which can then be sent to Couchbase Server using doc import 또는 doc upsert commands.

Visit our documentation for code samples 그리고 load data recipes.

Exporting data

Exporting data from Couchbase using the Couchbase Shell is a powerful way to back up your data, move it between environments, or simply extract it for analysis. The cbsh tool provides a straightforward command to export data directly from your Couchbase cluster into JSON files, making it easy to handle data outside of the database environment. The export counterparts to 열다 그리고 에서, are 저장 그리고 -로. You can use both commands to take tabular data from the shell and store it in files of the needed target format.

Visit our documentation for code samples 그리고 export data recipes.

벡터 검색

The headline feature of this release is the support for 벡터 검색. This capability allows you to perform similarity searches on a given corpus of document, all from a command line (CLI) interface. This is super useful to try and test your models and conduct ad-hoc vector searches easily via command line.

Vector search in Couchbase is powered by the integration of AI/ML models that convert text, images, or other data types into vectors. These vectors can then be compared to find similar items, providing a more relevant search experience compared to traditional keyword-based approaches.

Before users can start vector search, users need to define which large language model (LLM) they want to use. Currently, cbsh supports the following LLMs:

  1. OpenAI
  2. Gemini (Google)
  3. Bedrock (AWS)

방문하기 LLM documentation for configuration samples.

Typically, vector search is a three step process:

1 – Generate embeddings for fields in a collection

This is typically done when documents are created or updated, or if already have an existing dataset, do it as a bulk operation. With cbsh, this can be accomplished using the vector enrich-doc command. For example, the following example has 3 parts piped together:

  1. Query for documents in landmark collection.
  2. Send the 콘텐츠 field from the previous part’s resultset to LLM to generate vector embeddings. In this step the specified field is sent to LLM’s endpoint and the response is captured. Note that you must have LLM definition configured in the config file. If you have multiple models you want to experiment with, you can define multiple LLM in the config file and switch the LLM using cb-env LLM <identifier> command. All the LLM’s return back a default number of dimensions but you can override it using the –dimensions options. This command, by default, stores the vector in a field called fieldVector, which is contentVector in our example since the name of our field is 콘텐츠. You can override the default name of the vector field by using the –vectorField option.
  3. Save the vector embeddings by upserting it back to the database. 

This command sends the specified field (content) to the LLM defined in the config file which generates and returns vector embeddings. The returned vector embeddings are saved in the document, assuming the piped document has an id and content field. If not, user can specify a custom ID and content field.

Note that this command assumed that default bucket is set to travel-sample.

2 – Create a vector index for saved embeddings

This is always run after step 1. With cbsh, this can be accomplished using the create-index command The following command will create a new vector index named landmark-contentVector-index over vectors with dimension 1024. Note that the dimensions specified here must match the dimensions value in step 1. If you use the default value of dimension from your LLM, you can check this number from LLM’s documentation or just count the number of vector elements that were generated in step 1:

3 – Generate vector embedding for search keyword

3단계: Generate vector embedding for a search keyword using vector enrich-text command and conduct a vector search against the vector index using the 벡터 검색 command:

Finally, the result of a vector search can be piped into a doc or subdoc 얻다 to retrieve the contents of the found documents. Additionally, we can make the output prettier by only printing relevant fields:

Key-Value (KV) operation support

Couchbase shell natively supports performing key value operations. Key-value operations are unique to Couchbase and provide very fast CRUD operations for documents stored in Couchbase. 

cbsh command to read documents via KV service

You can retrieve a document with doc get:

To distinguish the actual content from the metadata, the content is nested in the content field. If you want to have everything at the toplevel, you can pipe to the flatten command:

0

And you can get multiple documents by using a command like below:

1

cbsh command to write documents via KV service

Documents can be mutated with doc insert, doc upsert 그리고 doc replace.

All those three commands take similar arguments. If you only want to mutate a single document, passing in the ID and the content as arguments is the simplest way:

2

Documents can be removed with doc remove.

3

There are many more KV operations you can do such as subdoc get. Please visit our documentation to learn more about KV operations.

Query data using SQL++

Running SQL++ queries using the 카우치베이스 셸 is one of the most powerful features of the tool, enabling you to interact with your Couchbase data in a flexible and efficient manner. SQL++, an extension of SQL designed for JSON data, allows you to perform complex queries, including joins, aggregates, and subqueries, directly from the command line with cbsh.

For example, we can see how many airlines are operating in ‘France’ in travel-sample data:

4

SQL++ is even more powerful as users can use named parameters and also use piping (|) to redirect the query command resultset to other commands. Visit our 문서화 자세한 내용은.

Get started

To help you get started with cbsh, we’ve prepared a detailed getting started guide on our 문서화 website. Here’s a quick overview of how to begin:

  • Getting cbsh: Download cbsh for your operating system from the Couchbase shell website.
  • Connect to Your Cluster: Recommended way is to create a config file as specified in config file documentation.
  • Perform CRUD operations, run queries, 또는 벡터 검색, and leverage Couchbase’s powerful features. To get you started very quickly, our documentation provides existing recipes for some common use cases.

Community and open source support

We believe in the power of community and open-source development. Couchbase cbsh is open source, and we encourage you to contribute, provide feedback, and join the conversation. Join the 카우치베이스 포럼 또는 Couchbase Discord.

Further reading

To learn more, check out our 문서 사이트. It goes into more detail on various supported commands and configurations, especially around connection credentials, and examples of piping commands together to achieve desired results.

Happy command shell!

카우치베이스 팀



이 기사 공유하기

작가

댓글 남기기

카우치베이스 카펠라를 시작할 준비가 되셨나요?

개발 시작하기

NoSQL을 탐색하고, 리소스를 찾아보고, 튜토리얼을 시작하려면 개발자 포털을 확인하세요.

카펠라 프리 사용하기

단 몇 번의 클릭으로 카우치베이스(Couchbase)를 직접 체험해 보세요. Capella DBaaS는 시작하기 가장 쉽고 빠른 방법입니다.

연락해

Couchbase 제품군에 대해 더 알고 싶으신가요? 저희가 도와드리겠습니다.