Time for action – writing a simple phrase query example

When using one of the internet search engines to search for a sequence of words, we can generally define the entire sequence as a unique term for search, wrapping it with the " character. With Solr, we are able to perform similar queries. We will call a sequence of words a phrase, and we will be able to handle it as a unique object:

>> curl -X GET 'http://localhost:8983/solr/paintings_readonly/select?q=abstract:%22original%20oil%22~20&wt=json&indent=true'

Notice how in this example %22 is the encoding for the " character.

What just happened?

In this little example, we are using the q=abstract:"original oil"~20 query with the proper HTTP encoding for characters. Notice that when using a phrase query, we could handle the entire phrase between double quotes as if it were a single term. So, we could search for exact match for it, boost it, apply wildcards, or use a fuzzy search, as we did in our example.

When used with phrases, the fuzzy search syntax denotes a particular kind of search that is generally defined as a proximity search. In our example, we will find both occurrences of the terms original and oil no more than 20 terms distant from each other. In our example, this could give us results for documents containing small paragraphs with either of the terms, or, for example, documents containing the phrase originally painted as oil.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.45.5