If you’ve ever had to write multiple queries just to capture all the variations of a phrase, you know how repetitive and messy it can get. With the new OR support inside phrases, you can match “happy customer” and “sad customer”—plus any other variation—in a single, clean query.
What’s New in Manticore Search 13.6.7
We’re pleased to announce that
Manticore Search 13.6.7
has been released with enhanced support for this useful feature. The OR operator (|
) inside phrase operators (quotes) provides flexible phrase matching that can improve how you build search functionality.
The Magic Behind OR in Phrases
Traditional search engines make you choose between exact phrase matching and loose keyword matching. But what if you need something in between? That’s where OR operators inside phrases shine. Each option is checked at the same position within the phrase, and the phrase matches if any of the alternatives fit that position.
Syntax That Makes Sense
"( a | b ) c" -- Either "a c" or "b c"
"( ( a b c ) | d ) e" -- Either "a b c e" or "d e"
"man ( happy | sad ) but all ( ( as good ) | ( as fast ) )" -- Complex nested possibilities
Let’s See It in Action
Let’s create a real-world example using customer feedback data. First, we’ll set up our test environment:
-- Clean slate for easy reproduction
DROP TABLE IF EXISTS phrase_or_demo;
CREATE TABLE phrase_or_demo (title TEXT, content TEXT, category TEXT);
INSERT INTO phrase_or_demo (id, title, content, category) VALUES
(1, 'Happy Customer Review', 'I am a very happy customer with excellent service', 'reviews'),
(2, 'Sad Customer Feedback', 'I am a very sad customer with poor experience', 'reviews'),
(3, 'Customer Service Report', 'The customer was happy but had some concerns', 'reports'),
(4, 'Angry Customer Complaint', 'I am an angry customer demanding refund', 'complaints'),
(5, 'Neutral Customer Survey', 'The customer seemed neutral about our service', 'surveys'),
(6, 'Fast Delivery Service', 'Our delivery service is really fast and reliable', 'services'),
(7, 'Slow Delivery Issues', 'The delivery was extremely slow this time', 'issues'),
(8, 'Good Service Quality', 'We provide good service to all customers', 'services'),
(9, 'Bad Service Report', 'There were complaints about bad service quality', 'reports'),
(10, 'Customer Happy Experience', 'The happy customer left positive feedback', 'feedback'),
(11, 'Premium Quality Product', 'This is a premium quality item with excellent features', 'products'),
(12, 'Budget Quality Option', 'A budget quality alternative for cost-conscious buyers', 'products'),
(13, 'Standard Quality Service', 'Our standard quality offering meets basic needs', 'services');
Example 1: Catch All Emotional States
Query: "(happy | sad | angry) customer"
SELECT * FROM phrase_or_demo WHERE MATCH('"(happy | sad | angry) customer"')
Result:
+------+---------------------------+---------------------------------------------------+------------+
| id | title | content | category |
+------+---------------------------+---------------------------------------------------+------------+
| 2 | Sad Customer Feedback | I am a very sad customer with poor experience | reviews |
| 4 | Angry Customer Complaint | I am an angry customer demanding refund | complaints |
| 1 | Happy Customer Review | I am a very happy customer with excellent service | reviews |
| 10 | Customer Happy Experience | The happy customer left positive feedback | feedback |
+------+---------------------------+---------------------------------------------------+------------+
4 rows in set (0.00 sec)
Why this matters: Instead of writing three separate phrase queries and combining them with OR, you get precise phrase matching with one elegant query.
Example 2: Service Quality Variations
Query: "(good | bad | premium | budget | standard) (service | quality)"
SELECT * FROM phrase_or_demo WHERE MATCH('"(good | bad | premium | budget | standard) (service | quality)"');
Result:
+------+--------------------------+--------------------------------------------------------+----------+
| id | title | content | category |
+------+--------------------------+--------------------------------------------------------+----------+
| 8 | Good Service Quality | We provide good service to all customers | services |
| 9 | Bad Service Report | There were complaints about bad service quality | reports |
| 11 | Premium Quality Product | This is a premium quality item with excellent features | products |
| 12 | Budget Quality Option | A budget quality alternative for cost-conscious buyers | products |
| 13 | Standard Quality Service | Our standard quality offering meets basic needs | services |
+------+--------------------------+--------------------------------------------------------+----------+
5 rows in set (0.00 sec)
The advantage: One query captures all quality - service combinations with exact phrase precision.
Beyond Basic Phrases: quorum and Proximity
The OR operator isn’t limited to simple phrases. Sometimes you need more flexibility like matching documents even if not every term is present, or finding terms that are close together but not necessarily in exact order. That’s where quorum and proximity operators come in, and they work seamlessly with OR.
Quorum with OR: Flexible Fuzzy Matching
The quorum operator with OR gives you sophisticated fuzzy matching where only one word from each OR group counts toward the threshold:
-- Find documents with at least 2 out of these word groups
SELECT id, content FROM phrase_or_demo WHERE MATCH('@content "(excellent | good | premium) (service | quality | experience) customer"/2');
Result:
+------+--------------------------------------------------------+
| id | content |
+------+--------------------------------------------------------+
| 8 | We provide good service to all customers |
| 1 | I am a very happy customer with excellent service |
| 11 | This is a premium quality item with excellent features |
| 2 | I am a very sad customer with poor experience |
| 5 | The customer seemed neutral about our service |
+------+--------------------------------------------------------+
5 rows in set (0.00 sec)
Explanation: This matches documents containing at least 2 of the 3 word groups: (excellent|good|premium), (service|quality|experience), and “customer”.
Advanced quorum Example
-- Match documents with at least 50% of these emotion/service combinations
SELECT id, title FROM phrase_or_demo
WHERE MATCH('"(happy | satisfied) (customer | experience) (excellent | good) (service | quality)"/0.5');
Proximity with OR: Nearby Alternatives
The proximity operator with OR checks each alternative separately within the specified distance:
-- Find "delivery" within 3 words of either "fast" or "slow"
SELECT id, title, content FROM phrase_or_demo WHERE MATCH('"(fast | slow) delivery"~3');
Result:
+------+-----------------------+--------------------------------------------------+
| id | title | content |
+------+-----------------------+--------------------------------------------------+
| 7 | Slow Delivery Issues | The delivery was extremely slow this time |
| 6 | Fast Delivery Service | Our delivery service is really fast and reliable |
+------+-----------------------+--------------------------------------------------+
2 rows in set (0.00 sec)
Complex Proximity Example
-- Customer and emotional state within 5 words, plus quality terms
SELECT id, title, content FROM phrase_or_demo WHERE MATCH('"customer (happy | sad | angry)"~2 (quality | service | experience)');
Result:
+------+---------------------------+---------------------------------------------------+
| id | title | content |
+------+---------------------------+---------------------------------------------------+
| 10 | Customer Happy Experience | The happy customer left positive feedback |
| 2 | Sad Customer Feedback | I am a very sad customer with poor experience |
| 1 | Happy Customer Review | I am a very happy customer with excellent service |
| 3 | Customer Service Report | The customer was happy but had some concerns |
+------+---------------------------+---------------------------------------------------+
4 rows in set (0.00 sec)
Comparison: Traditional vs. Advanced
Traditional Approach (Multiple Full-text Statements)
-- The old way: multiple separate queries
SELECT id, title FROM phrase_or_demo WHERE MATCH('"happy customer"|"sad customer"|"angry customer"');
Modern Approach (Single OR Phrase)
-- The elegant way: one query to rule them all
SELECT id, title FROM phrase_or_demo WHERE MATCH('"(happy | sad | angry) customer"');
Real-World Applications
1. E-commerce Product Search
-- Capture all color and size variations
"(red | blue | green | black) (shirt | t-shirt | tee) (small | medium | large)"
2. Content Management Systems
-- Track document status changes
"(draft | published | archived | deleted) (document | article | post)"
3. Customer Support Ticket Analysis
-- Categorize support issues with quorum
"(urgent | critical | high) (priority | importance) (bug | issue | problem)"/2
4. Social Media Sentiment Monitoring
-- Capture brand mentions with emotional context
"@brand (love | hate | like | dislike) (product | service | experience)"~5
5. Medical Records Search
-- Find patient symptoms with proximity
"patient (experienced | reported | complained) (pain | discomfort | symptoms)"~4
6. Financial Transaction Analysis
-- Track transaction types and statuses
"(credit | debit | transfer) (completed | pending | failed | cancelled)"
Advanced Usage Patterns
1. Layered Precision
Combine phrase OR with other operators for surgical precision:
@title "(urgent | critical) (update | patch)" @body "security"
2. Performance Optimization
Use quorum with OR for fuzzy matching that may be faster than wildcard searches:
"(run | running | runner | runs) (fast | quick | speed)"/1
3. Contextual Flexibility
Leverage proximity OR for natural language variations:
"user (wants | needs | requires) (feature | functionality)"~3
Key Benefits
- Precision: Maintain exact phrase structure while accommodating variations
- Maintainability: One query to update instead of managing multiple variations
- Analytics: Unified result sets make analysis and ranking more meaningful
- Flexibility: Handles real-world language variations effectively
The Bottom Line
OR operators inside phrases provide a useful middle ground between rigid exact-match searching and loose keyword matching. Whether you’re building e-commerce search, analyzing customer feedback, or creating content discovery systems, this feature offers the precision of phrases with the flexibility of alternatives.
Manticore Search 13.6.7 includes this functionality as part of its comprehensive text search capabilities. The combination of phrase, proximity, and quorum operators with OR functionality provides additional options for handling complex search requirements.
To learn more about this feature and other improvements, see the Manticore Search 13.6.7 release notes .