11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

"jakarta apache" OR jakarta<br />

The Boolean Operator +<br />

The + symbol (also known as the "required" operator) requires that the term after the + symbol exist somewhere<br />

in a field in at least one document in order for the query to return a match.<br />

For example, to search for documents that must contain "jakarta" and that may or may not contain "lucene," use<br />

the following query:<br />

+jakarta lucene<br />

This operator is supported by both the standard query parser and the DisMax query parser.<br />

The Boolean Operator AND (&&)<br />

The AND operator matches documents where both terms exist anywhere in the text of a single document. This is<br />

equivalent to an intersection using sets. The symbol && can be used in place of the word AND.<br />

To search for documents that contain "jakarta apache" and "<strong>Apache</strong> Lucene," use either of the following queries:<br />

"jakarta apache" AND "<strong>Apache</strong> Lucene"<br />

"jakarta apache" && "<strong>Apache</strong> Lucene"<br />

The Boolean Operator NOT (!)<br />

The NOT operator excludes documents that contain the term after NOT. This is equivalent to a difference using<br />

sets. The symbol ! can be used in place of the word NOT.<br />

The following queries search for documents that contain the phrase "jakarta apache" but do not contain the<br />

phrase "<strong>Apache</strong> Lucene":<br />

"jakarta apache" NOT "<strong>Apache</strong> Lucene"<br />

"jakarta apache" ! "<strong>Apache</strong> Lucene"<br />

The Boolean Operator -<br />

The - symbol or "prohibit" operator excludes documents that contain the term after the - symbol.<br />

For example, to search for documents that contain "jakarta apache" but not "<strong>Apache</strong> Lucene," use the following<br />

query:<br />

"jakarta apache" -"<strong>Apache</strong> Lucene"<br />

Escaping Special Characters<br />

<strong>Solr</strong> gives the following characters special meaning when they appear in a query:<br />

+ - && || ! ( ) { } [ ] ^ " ~ * ? : /<br />

To make <strong>Solr</strong> interpret any of these characters literally, rather as a special character, precede the character with<br />

a backslash character \. For example, to search for (1+1):2 without having <strong>Solr</strong> interpret the plus sign and<br />

parentheses as special characters for formulating a sub-query with two terms, escape the characters by<br />

preceding each one with a backslash:<br />

\(1\+1\)\:2<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

258

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!