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.

mod_date:[20020101 TO 20030101]<br />

Range queries are not limited to date fields or even numerical fields. You could also use range queries with<br />

non-date fields:<br />

title:{Aida TO Carmen}<br />

This will find all documents whose titles are between Aida and Carmen, but not including Aida and Carmen.<br />

The brackets around a query determine its inclusiveness.<br />

Square brackets [ ] denote an inclusive range query that matches values including the upper and lower<br />

bound.<br />

Curly brackets { } denote an exclusive range query that matches values between the upper and lower<br />

bounds, but excluding the upper and lower bounds themselves.<br />

You can mix these types so one end of the range is inclusive and the other is exclusive. Here's an<br />

example: count:{1 TO 10]<br />

Boosting a Term with ^<br />

Lucene/<strong>Solr</strong> provides the relevance level of matching documents based on the terms found. To boost a term use<br />

the caret symbol ^ with a boost factor (a number) at the end of the term you are searching. The higher the boost<br />

factor, the more relevant the term will be.<br />

Boosting allows you to control the relevance of a document by boosting its term. For example, if you are<br />

searching for<br />

"jakarta apache" and you want the term "jakarta" to be more relevant, you can boost it by adding the ^ symbol<br />

along with the boost factor immediately after the term. For example, you could type:<br />

jakarta^4 apache<br />

This will make documents with the term jakarta appear more relevant. You can also boost Phrase Terms as in<br />

the example:<br />

"jakarta apache"^4 "<strong>Apache</strong> Lucene"<br />

By default, the boost factor is 1. Although the boost factor must be positive, it can be less than 1 (for example, it<br />

could be 0.2).<br />

Constant Score with ^=<br />

Constant score queries are created with ^= , which sets the entire clause to the<br />

specified score for any documents matching that clause. This is desirable when you only care about matches for<br />

a particular clause and don't want other relevancy factors such as term frequency (the number of times the term<br />

appears in the field) or inverse document frequency (a measure across the whole index for how rare a term is in<br />

a field).<br />

Example:<br />

(description:blue OR color:blue)^=1.0 text:shoes<br />

Specifying Fields in a Query to the Standard Query Parser<br />

Data indexed in <strong>Solr</strong> is organized in fields, which are defined in the <strong>Solr</strong> Schema. Searches can take advantage<br />

of fields to add precision to queries. For example, you can search for a term only in a specific field, such as a title<br />

field.<br />

The Schema defines one field as a default field. If you do not specify a field in a query, <strong>Solr</strong> searches only the<br />

default field. Alternatively, you can specify a different field or a combination of fields in a query.<br />

To specify a field, type the field name followed by a colon ":" and then the term you are searching for within the<br />

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

256

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

Saved successfully!

Ooh no, something went wrong!