ParseException — Cannot Parse Query
Your search query has a typo or formatting mistake that Solr cannot understand. This guide shows you exactly what went wrong, how to spot it, and how to fix it — with real examples.
What Happened?
The Error: Cannot parse '...': Encountered " ":" ": "" at line 1, column N
You sent a search query to Solr that contains a syntax mistake. Solr tried to read your query like a sentence, but hit a character (like a :) that doesn't make sense in that position. It's like writing "Find me all blue AND" — the sentence just stops mid-thought.
Key difference: This error happens when searching (querying), not when adding data. It's your search request that's broken, not your data.
Real-World Example
Here's an actual broken query from a real Solr log:
The application code was supposed to send two separate things: a query q=ss_bundle:url_builder and a filter fq=ss_bundle:toc. But due to a bug, they got glued together into one broken string.
Common Causes
Solr operators like AND, OR, NOT need spaces on both sides. catANDdog is one word to Solr, not a boolean search.
Characters like : ( ) [ ] + - have special meaning in Solr queries. If user input contains them, they must be escaped with a backslash: \:
Application code that builds query URLs by concatenating strings often forgets the & separator between parameters, mashing q= and fq= into one broken value.
Every ( needs a matching ), and every " needs a closing ". A query like (title:hello without a closing parenthesis will fail.
How to Read the Error Message
The error message tells you exactly where it broke. Let's decode it:
How to Fix It
Fix 1 — Properly Separate Query Parameters
If your query and filter query got concatenated, they need to be separate URL parameters:
// WRONG — parameters mashed together /solr/myindex/select?q=ss_bundle:url_builderORfq=ss_bundle:toc // CORRECT — separate q and fq parameters with & /solr/myindex/select?q=ss_bundle:url_builder&fq=ss_bundle:toc
Fix 2 — Add Spaces Around Boolean Operators
// WRONG — no spaces around OR q=title:helloORtitle:world // CORRECT — spaces around OR q=title:hello OR title:world
Fix 3 — Escape Special Characters in User Input
If your users type search terms that contain colons, parentheses, or other special characters, you must escape them before sending to Solr:
// Special characters that need escaping in Solr queries: // + - && || ! ( ) { } [ ] ^ " ~ * ? : \ / // PHP example — escape user input: $userQuery = preg_replace( '/([+\-!(){}\[\]^"~*?:\\\\/]|&&|\|\|)/', '\\\\$1', $userQuery );
# Python example: import re user_query = re.sub(r'([+\-!(){}\[\]^"~*?:\\/]|&&|\|\|)', r'\\\1', user_query)
Fix 4 — Balance Your Parentheses and Quotes
// WRONG — unclosed parenthesis q=(title:hello OR title:world // CORRECT — balanced parentheses q=(title:hello OR title:world) // WRONG — unclosed quote q=title:"hello world // CORRECT — balanced quotes q=title:"hello world"
Solr Special Characters Cheat Sheet
| Character | Meaning in Solr | To Use Literally |
|---|---|---|
| : | Field separator (field:value) |
\: |
| ( ) | Grouping | \( \) |
| " " | Exact phrase search | \" |
| + - | Required / excluded terms | \+ \- |
| * ? | Wildcard characters | \* \? |
| [ ] | Range queries | \[ \] |
| ~ | Fuzzy / proximity search | \~ |
How to Prevent This
Libraries like SolrJ (Java), Solarium (PHP), or pysolr (Python) handle query escaping and parameter building for you. Don't build raw query URLs by hand.
Never put raw user search terms directly into a Solr query. Always escape special characters first, or use the eDisMax query parser which is more forgiving with user input.
Log the full query URL your app sends to Solr. When errors happen, check the Error Audit dashboard — it shows the exact query that failed, so you can spot the mistake immediately.
Need More Help?
Check your Error Audit for the exact query that failed, or reach out to the Opensolr team.