CLI Query Command
Use thequery command to search your documentation from the command line:
Query Options
The search query string
Filter results to a specific library (e.g.,
--library openground)Filter results by version (e.g.,
--version v1.0.0)Number of results to return (can be overridden from config)
Examples
Query Results Format
Query results are returned in a structured markdown format:- Title: The page title
- Snippet: Relevant content chunk
- Source: Original URL
- Version: Library version
- Score: Relevance score (lower is better for distance-based metrics)
- Tool hint: JSON payload for fetching full content (useful for MCP integration)
Programmatic Query (Python)
You can also query from Python code:Search Parameters
query(str): Search query textversion(str): Version filter (required)db_path(Path): Path to LanceDB database (default:~/.local/share/openground/lancedb)table_name(str): LanceDB table name (default:"documents")library_name(str, optional): Filter by library nametop_k(int): Number of results to return (default: 10)show_progress(bool): Show embedding progress bar (default: True)
Getting Full Page Content
To retrieve the complete content of a specific page:Hybrid Search Explained
OpenGround uses hybrid search that combines:- Semantic Search: Uses embeddings (384-dimensional vectors by default) to find conceptually similar content
- BM25 Text Search: Traditional keyword-based search for exact matches
- Technical documentation with specific terminology
- Conceptual queries that need semantic understanding
- Mixed queries combining exact terms and concepts
What embedding model is used?
What embedding model is used?
By default, OpenGround uses
BAAI/bge-small-en-v1.5 which produces 384-dimensional embeddings. You can configure a different model in your config file using openground config set embeddings.embedding_model "model-name".How is relevance scored?
How is relevance scored?
LanceDB’s hybrid search combines vector similarity (using distance metrics) with BM25 scores. Lower distance scores indicate higher relevance. The exact scoring algorithm is managed by LanceDB’s query engine.
Can I search across all versions?
Can I search across all versions?
Currently, queries require a version filter. To search all versions, you would need to run multiple queries with different version values. This is by design to ensure version-specific accuracy.
What if no results are found?
What if no results are found?
The query will return
"Found 0 matches." This could mean:- The library/version doesn’t exist in your database
- No content matches your query
- The embedding model doesn’t have sufficient context
openground list-libraries to verify what’s available.Query Performance Tips
- Keep
top_kreasonable (5-10) for faster results - Use library filters when you know the source
- Be specific in your queries for better semantic matching
- Use version filters to narrow results