collection

package
v0.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CollectionCmd = &cobra.Command{
	Use:     "collection",
	Aliases: []string{"col", "cols"},
	Short:   "Collection management",
	Long: `Manage vector database collections.

This command provides subcommands to list, view, and delete collections.`,
}

CollectionCmd represents the collection command

View Source
var CountCmd = &cobra.Command{
	Use:     "count",
	Aliases: []string{"c"},
	Short:   "Count collections",
	Long: `Count the number of collections in the vector database.

This command returns the total number of collections.

Example:
  weave collection count`,
	Args: cobra.NoArgs,
	Run:  runCollectionCount,
}

CountCmd represents the collection count command

View Source
var CreateCmd = &cobra.Command{
	Use:     "create COLLECTION_NAME",
	Aliases: []string{"c"},
	Short:   "Create a collection",
	Long: `Create a new collection in the vector database.

This command creates a collection with the specified name and schema.
You can use the --text or --image flags for standard schemas, use a named
schema from config.yaml/schemas_dir, specify a schema file, or use custom
fields and embedding model.

For --text and --image collections, you must specify how to handle metadata:
- --flat-metadata: Flatten metadata fields into individual properties
- --json-metadata: Keep metadata as a single JSON field

Examples:
  # Create text collection with flattened metadata (recommended)
  weave collection create MyDocsCol --text --flat-metadata

  # Create text collection with JSON metadata
  weave collection create MyDocsCol --text --json-metadata

  # Create image collection with flattened metadata
  weave collection create MyImagesCol --image --flat-metadata

  # Create collection using a named schema from config.yaml or schemas_dir
  weave collection create MyDocsCol --schema RagMeDocs
  weave collection create MyDocsCol --schema TestSchema

  # Create collection from a YAML schema file
  weave collection create MyCollection --schema-yaml-file schema.yaml

  # Create collection with default schema and custom options
  weave collection create MyCollection
  weave collection create MyCollection --embedding-model text-embedding-ada-002
  weave collection create MyCollection --fields "title:string,description:text"`,
	Args: cobra.ExactArgs(1),
	Run:  runCollectionCreate,
}

CreateCmd represents the collection create command

View Source
var DeleteAllCmd = &cobra.Command{
	Use:     "delete-all",
	Aliases: []string{"da"},
	Short:   "Clear all collections (delete all documents)",
	Long: `Clear all collections by deleting all documents from them.

⚠️  WARNING: This is a destructive operation that will permanently
delete ALL documents in ALL collections. The collection schemas will
remain but will be empty. Use with extreme caution!

This command requires double confirmation:
1. First confirmation: Standard y/N prompt
2. Second confirmation: Red warning requiring exact "yes" input

Use --force to skip confirmations in scripts.

Example:
  weave collection delete-all`,
	Args: cobra.NoArgs,
	Run:  runCollectionDeleteAll,
}

DeleteAllCmd represents the collection delete-all command

View Source
var DeleteCmd = &cobra.Command{
	Use:     "delete COLLECTION_NAME [COLLECTION_NAME...]",
	Aliases: []string{"del", "d"},
	Short:   "Clear one or more collections (delete all documents)",
	Long: `Clear one or more collections by deleting all documents from them.

⚠️  WARNING: This is a destructive operation that will permanently
delete all documents in the specified collection(s). The collection
schema will remain but will be empty. Use with caution!

You can specify collections in multiple ways:
1. By collection name(s): weave cols delete MyCollection
2. By pattern: weave cols delete --pattern "WeaveDocs*"
3. By multiple names: weave cols delete Collection1 Collection2 Collection3

Pattern types (auto-detected):
- Shell glob: WeaveDocs*, Test*, *Docs
- Regex: WeaveDocs.*, ^Test.*$, .*Docs$

Examples:
  weave collection delete MyCollection
  weave collection delete Collection1 Collection2 Collection3
  weave collection delete --pattern "WeaveDocs*"`,
	Args: func(cmd *cobra.Command, args []string) error {
		pattern, _ := cmd.Flags().GetString("pattern")
		if pattern == "" && len(args) == 0 {
			return fmt.Errorf("requires at least 1 collection name or --pattern flag")
		}
		return nil
	},
	Run: runCollectionDelete,
}

DeleteCmd represents the collection delete command

View Source
var DeleteSchemaCmd = &cobra.Command{
	Use:     "delete-schema COLLECTION_NAME",
	Aliases: []string{"ds"},
	Short:   "Delete collection schema",
	Long: `Delete the schema of a collection.

This command removes the schema definition from the collection.
The collection and its documents will remain, but the schema will be deleted.

⚠️  WARNING: This is a destructive operation that will permanently
delete the schema definition. Use with caution!

This command requires double confirmation:
1. First confirmation: Standard y/N prompt
2. Second confirmation: Red warning requiring exact "yes" input

Use --force to skip confirmations in scripts.

You can specify collections in multiple ways:
1. By collection name: weave cols delete-schema MyCollection
2. By pattern: weave cols delete-schema --pattern "Test*"

Pattern types (auto-detected):
- Shell glob: Test*, WeaveDocs*, *Docs
- Regex: Test.*, ^WeaveDocs.*$, .*Docs$

Examples:
  weave collection delete-schema MyCollection
  weave collection delete-schema --pattern "Test*"`,
	Args: func(cmd *cobra.Command, args []string) error {
		pattern, _ := cmd.Flags().GetString("pattern")
		if pattern == "" && len(args) == 0 {
			return fmt.Errorf("requires collection name or --pattern flag")
		}
		return nil
	},
	Run: runCollectionDeleteSchema,
}

DeleteSchemaCmd represents the collection delete-schema command

View Source
var ListCmd = &cobra.Command{
	Use:     "list [database-name]",
	Aliases: []string{"ls", "l"},
	Short:   "List all collections",
	Long: `List all collections in the configured vector database.

This command shows:
- Collection names
- Document counts (if available)
- Collection metadata (if available)

If no database name is provided, it uses the default database.
Use 'weave config list' to see all available databases.`,
	Run: runCollectionList,
}

ListCmd represents the collection list command

View Source
var QueryCmd = &cobra.Command{
	Use:     "query COLLECTION \"query text\"",
	Aliases: []string{"q"},
	Short:   "Perform semantic search on a collection",
	Long: `Perform semantic search on a collection using natural language queries.

This command uses Weaviate's vector search capabilities to find the most relevant
documents based on semantic similarity to your query text.

Score Interpretation:
  Scores are normalized to spread results across a wider range:
  - < 0.3: No good matches found (try rephrasing your query)
  - 0.3-0.5: Weak/marginal relevance
  - 0.5-0.7: Good semantic relevance
  - > 0.7: Strong semantic relevance

Examples:
  weave cols query MyDocs "machine learning algorithms"
  weave cols q MyDocs "artificial intelligence" --top_k 10
  weave cols query WeaveImages "sunset over mountains" --top_k 3
  weave cols q MyDocs "exact keywords" --bm25
  weave cols q MyDocs "search term" --search-metadata --bm25`,
	Args: cobra.ExactArgs(2),
	Run:  runCollectionQuery,
}

QueryCmd represents the collection query command

View Source
var ShowCmd = &cobra.Command{
	Use:     "show COLLECTION_NAME",
	Aliases: []string{"s"},
	Short:   "Show collection details",
	Long: `Show detailed information about a collection.

This command displays:
- Collection schema
- Metadata information
- Document count
- Field definitions

Example:
  weave collection show MyCollection`,
	Args: cobra.ExactArgs(1),
	Run:  runCollectionShow,
}

ShowCmd represents the collection show command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL