Lucene allows for advanced search queries to be entered using keywords or symbols. Some examples are below:

Note that keywords must be in upper case.


Search Term

Result

a4 AND paper

returns products containing the word "a4" and the word "paper"

a4 OR paper

returns products containing the word "a4" or the word "paper"

paper NOT a5

returns products containing the word "paper" but not the word "a5"

paper AND (a4 OR a5)

return products containing the word "paper" and either "a4" or "a5"

"a4 paper"

returns products containing the string "a4 paper" (i.e the word paper must follows a4)

title:a4

returns products containing "a4" in the "title" field of the index


Note that "+" can be used instead of "AND" and "-" can be used instead of "NOT". The below are equivalent to the above first 4 queries

  • +a4 +paper
  • a4 paper
  • paper -a5
  • +paper +(a4 a5)


Search Queries in CSS

In CSS, we assume that when users enter a number of words, they want an "and" search to be performed.

Therefore, if a user enters "blue pen" as a search term in CSS, the system will perform the search "blue AND pen" against Lucene. If this search returns no results, a second search is done using "OR" so that the user will be presented with some results rather than none. If the user has entered a large number of words, they will be returned a large number of products, but the most relevant products will appear at the top of the list.

If the user enters any of the advanced search query terms, the query is passed straight through to Lucene without adding the "AND"s.

Any search containing ", +, -, NOT, OR, AND is passed directly to Lucene.


Related help