Oh, and I believe the syntax for advanced searches (tho I have not tested any) is as follows:
Solr's default search uses a superset of the Lucene query syntax, which offers precise search capabilities using special characters and operators.
Basic Syntax Components
- Fielded Searches: Search within a specific field by typing the field name followed by a colon and the term (e.g., title:AccessLog). If no field is specified, Solr searches a default field, often named text.
- Phrase Searches: To search for multiple words in a specific sequence, wrap them in double quotes (e.g., subject:"test email").
- Boolean Operators: Capitalized operators (AND, OR, NOT) or symbols (+, -) combine search clauses.
- AND (+): Ensures both terms are present (e.g., title:"Error 401" AND body:"Authorization is denied").
- OR (||): Matches documents containing either term (e.g., jakarta OR apache).
- NOT (-): Excludes terms from the results (e.g., title:401 -title:404).
- Grouping: Use parentheses to group clauses and control logic (e.g., (title:"Error 401" AND body:"Authorization is denied") OR title:Password).
Term Modifiers
- Wildcard Searches:
- ?: Matches a single character (e.g., te?t matches "test" and "text").
- *: Matches zero or more characters (e.g., tes* matches "test", "testing", "tester").
- Note: Wildcards cannot be the first character of a search term by default.
- Fuzzy Searches: Use the tilde ~ at the end of a single word term to find terms with similar spelling (e.g., roam~ matches "roams", "foam"). An optional number specifies the maximum edit distance, defaulting to 2 (e.g., roam~1).
- Proximity Searches: Use the tilde ~ at the end of a phrase with a numeric value to find words within a specific distance of each other (e.g., "jakarta apache"~10 finds "jakarta" and "apache" within 10 words).
- Range Searches: Specify a range of values for a field using square brackets [] for inclusive ranges and curly brackets {} for exclusive ranges. Wildcards can be used for open-ended ranges.
- Inclusive: popularity:[52 TO 10000]
- Exclusive: title:{Aida TO Carmen}
- Open-ended: field:[100 TO *]
- Boosting Terms: Use the caret ^ symbol with a positive number (boost factor) at the end of a term or phrase to increase its relevance score (e.g., jakarta^4 apache).
Escaping Special Characters
To search for any of the special characters that are part of the query syntax (+, -, &, |, !, (, ), {, }, [, ], ^, ", ~, *, ?, :, \), you must escape them with a backslash (\).