A disjunctive query is a database query that uses the logical OR operator to combine multiple filter conditions, requiring at least one of the specified predicates to be true for a record to be included in the result set. In the context of hybrid search within a vector database, it is commonly used to apply flexible metadata constraints, such as finding documents that are either from a specific category or published within a certain date range, before or during a semantic search operation.
Glossary
Disjunctive Query

What is a Disjunctive Query?
A disjunctive query is a fundamental logical operation in database and search systems that retrieves records matching at least one of several specified conditions.
This contrasts with a conjunctive query, which uses the AND operator and requires all conditions to be met. Efficient execution of disjunctive queries, especially over large-scale vector indexes, often involves optimization techniques like filter pushdown and the use of bitmap indexes to perform fast set unions. Understanding filter selectivity is crucial for query planners to determine the most efficient order of operations when disjunctive filters are combined with expensive approximate nearest neighbor (ANN) searches.
Key Characteristics of Disjunctive Queries
A disjunctive query uses the logical OR operator to combine filter conditions, requiring at least one predicate to be true for a record to match. This is a fundamental operation for broadening search results and modeling real-world 'any-of' scenarios.
Logical OR Semantics
The core of a disjunctive query is the logical OR operator. It combines multiple filter predicates such that a document is included in the result set if at least one of the conditions evaluates to true. This is formally expressed as predicate_A OR predicate_B OR .... For example, a query for documents where category = 'news' OR author = 'Jane Doe' returns all news articles plus all articles written by Jane Doe, including any that satisfy both conditions.
Broadens Result Sets
Disjunctive queries inherently increase recall by expanding the candidate pool. Unlike a conjunctive query (AND) which narrows results, an OR condition aggregates matches from multiple criteria. This is essential for exploratory search, faceted navigation where users select multiple options within a facet (e.g., 'show me shirts in red OR blue'), or building inclusive candidate sets for downstream reranking stages. The cardinality of the result set is at least as large as the largest individual predicate's result and at most the union of all.
Implementation in Query DSLs
Disjunctive logic is a first-class citizen in search and database Query Domain-Specific Languages (DSLs). It is expressed using explicit operators:
- Elasticsearch / OpenSearch:
{"bool": {"should": [ {...}, {...} ]}} - SQL:
WHERE category = 'A' OR tag = 'B' - Pinecone / Weaviate: Nested filter objects with an
"Or"operator at the root. These DSLs allow nesting disjunctions within conjunctions (e.g.,(A OR B) AND C) to create complex, precise logical trees for retrieval.
Interaction with Vector Search
In hybrid search systems, disjunctive filters are typically applied to the metadata before or during the vector similarity search. A query like (vector_similarity(query)) FILTER BY (department = 'Sales' OR department = 'Marketing') ensures results are semantically relevant and belong to either department. Efficient execution requires index structures like HNSW with filters or IVF with IDSelector that can prune graph traversal or cluster probing based on OR conditions, avoiding a full post-filter that could discard all vector results.
Performance Considerations
Disjunctive queries can be computationally more expensive than conjunctive ones for filtering systems. Key performance factors include:
- Index Support: Systems use bitmap indexes or inverted indexes to perform fast union operations for OR clauses.
- Selectivity: Low-selectivity (broad) OR predicates can generate large intermediate result sets, stressing memory. Optimizers may reorder predicates or choose different index access paths.
- Pushdown Efficiency: For ANN with filters, the ability to 'push' the OR condition into the vector index traversal is critical for performance. A naive post-filter after a vector search may yield zero results if the filter is too restrictive, wasting the initial ANN computation.
Contrast with Conjunctive Query
Disjunctive (OR) and conjunctive (AND) queries are logical duals. Their core difference is in result set inclusion:
- Disjunctive (OR):
A OR B→ Includes union of sets satisfying A and B. - Conjunctive (AND):
A AND B→ Includes intersection of sets satisfying A and B. A conjunctive query narrows and specifies ('this AND that'), while a disjunctive query broadens and aggregates ('this OR that'). Most complex business logic queries, expressed in a Query DSL, are compositions of both AND and OR operators within a single execution plan.
Implementation in Vector Search & Hybrid Retrieval
A disjunctive query, using the logical OR operator, is a fundamental filter for retrieving records where at least one of multiple conditions is true. In vector search systems, it enables flexible, broad-scope retrieval by unionizing candidate sets from different metadata criteria before or during similarity scoring.
In vector database execution, a disjunctive query is typically implemented by performing a union of intermediate result sets. For pre-filtering, the system evaluates each OR clause independently, often using efficient bitmap indexes, and merges the resulting document IDs before the approximate nearest neighbor (ANN) search. For post-filtering, a broad vector search is run first, and the results are filtered to retain items matching any of the OR conditions. Efficient implementations, such as HNSW with filters, integrate this logic directly into graph traversal to avoid full scans.
Within hybrid retrieval architectures, disjunctive logic is crucial for combining diverse evidence. A query for "patent filings OR trademark applications" might trigger separate lexical (BM25) and semantic (vector) searches for each term, with the results fused via reciprocal rank fusion (RRF). This approach increases recall by capturing documents relevant to any facet of the query. Query planners must estimate filter selectivity for each OR branch to choose an optimal execution order, balancing the cost of union operations against the precision of the final candidate set for reranking.
Disjunctive Query vs. Conjunctive Query
A comparison of the two fundamental logical operators used to combine filter predicates in database queries, particularly relevant for filtered vector search.
| Feature / Characteristic | Disjunctive Query (OR) | Conjunctive Query (AND) |
|---|---|---|
Logical Operator | OR | AND |
Result Set Inclusion Rule | A record is included if AT LEAST ONE of the specified conditions is true. | A record is included ONLY IF ALL of the specified conditions are true. |
Effect on Result Set Size | Tends to INCREASE the result set size (union of sets). | Tends to DECREASE the result set size (intersection of sets). |
Typical Use Case | Broadening search to capture diverse criteria (e.g., category='electronics' OR price<100). | Narrowing search with precise, cumulative constraints (e.g., category='electronics' AND price<100 AND brand='Acme'). |
Filter Selectivity | Low selectivity; fewer records are filtered out. | High selectivity; more records are filtered out. |
Performance Consideration | Can be less efficient if filters have low individual selectivity, as many records may qualify. | Can be highly efficient with selective filters, quickly narrowing the candidate pool. |
Implementation in Vector Search | Often requires specialized index support (e.g., filtered HNSW) or post-filtering to avoid missing relevant vectors. | Easier to optimize via pre-filtering; a common pattern for scoping vector search to a relevant subset. |
Example Boolean Expression |
|
|
Frequently Asked Questions
A disjunctive query uses the logical OR operator to combine filter conditions, requiring at least one predicate to be true for a record to match. This glossary addresses common technical questions about its implementation and optimization in vector search systems.
A disjunctive query is a database query that uses the logical OR operator to combine multiple filter conditions, requiring that at least one of the specified predicates be true for a record to be included in the result set. This contrasts with a conjunctive query (using AND), which requires all conditions to be true. In the context of vector databases and hybrid search, disjunctive queries are commonly applied to metadata fields to broaden the search scope. For example, a query for documents that are tagged as "finance" OR have a category of "annual-report" will return all records satisfying either condition, creating a union of the two filtered sets.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Disjunctive queries are a fundamental component of complex search logic. Understanding related concepts is essential for designing precise retrieval systems that combine vector similarity with structured metadata constraints.
Conjunctive Query
A conjunctive query uses the logical AND operator to combine multiple filter conditions. A record must satisfy all specified predicates to be included in the result set. This is the inverse of a disjunctive query and is used for narrowing results.
- Example:
category = 'legal' AND date >= '2024-01-01' AND author = 'counsel' - In vector search, a conjunctive filter might be applied before an ANN search to ensure all retrieved documents meet strict business rules.
Boolean Filter
A Boolean filter is a logical expression constructed using AND, OR, and NOT operators applied to metadata fields. Disjunctive and conjunctive queries are specific types of Boolean filters.
- Key Use: Creating complex, nested logic for precise document inclusion/exclusion.
- Example:
(department = 'sales' OR department = 'marketing') AND NOT status = 'archived' - In a Query DSL, Boolean filters define the hard constraints for hybrid or filtered search.
Filtered Search
Filtered search is a retrieval process where metadata-based constraints narrow the candidate set before or during a similarity or keyword search. Disjunctive queries are a primary method for expressing these constraints.
- Architecture: Critical for enterprise RAG and e-commerce, where results must obey business rules (e.g.,
region = 'EU' OR license = 'global'). - Performance Impact: Applying filters pre-search (pre-filtering) reduces the index search space, while post-search (post-filtering) can cause result starvation if filters are too restrictive.
Filter Selectivity
Filter selectivity estimates the proportion of records that will satisfy a filter predicate. It is a crucial metric for database query optimizers when planning the execution of disjunctive or conjunctive queries.
- Calculation: Expressed as a fraction (e.g., 0.05 for 5%). A low-selectivity filter returns few rows.
- Optimization Use: The optimizer may decide to evaluate a high-selectivity disjunctive clause (e.g.,
status = 'active') later in the plan, as it eliminates few rows. Understanding selectivity helps predict query performance and avoid bottlenecks.
ANN with Filters
ANN with Filters refers to algorithms for Approximate Nearest Neighbor search that are modified to respect hard metadata constraints during graph or tree traversal. This solves the challenge of efficiently executing a vector similarity search under a disjunctive filter.
- Core Problem: Applying a filter after a pure vector search (post-filtering) can discard all relevant results.
- Solutions: Algorithms like HNSW with Filters or DiskANN integrate filtering logic into the graph traversal, pruning paths that lead to nodes violating the filter (e.g.,
category = 'A' OR category = 'B').
Query DSL
A Query Domain-Specific Language (DSL) is a specialized syntax for expressing complex search requests. It provides a declarative way to combine vector similarity, keyword matching (BM25), and Boolean filters (including disjunctive queries) in a single statement.
- Example Clause:
{ vector: [0.1, 0.2,...], filter: { or: [ { author: 'Smith' }, { department: 'R&D' } ] } } - Purpose: Abstracts complexity for developers and allows the database optimizer to generate the most efficient execution plan for the combined query.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us