Advanced Search Options

Prev Next

Our Online Code Hosting solution uses Elasticsearch to perform searches across code, ordinance, and document content types. Many users will find that simply entering one or more keywords into the Code Library search box will help them find what they're looking for. We provide basic instructions for how to complete those searches in the Search a Code article.

However, power users may want to be a bit more specific with their searches. This article will outline the modifiers and operators that can be entered into the search box for more advanced, specific searches.

An example Search or jump to box with an exact-phrase quotation search entered.

Search Defaults

Searches with no modifiers or operators follow these default settings:

  • Keywords: Our search engine returns documents with a high frequency of matched keywords. A two-keyword search, such as zoning ordinance, only returns documents that contain both keywords. A search with more than two keywords returns documents that match at least 75% of the keywords.

  • Stemming: All search terms are stemmed by default. Stemming matches related word forms, so searching for permit also returns results for permits, permitting, and permitted. Terms in quotation marks are not stemmed.

  • Synonyms: Our search engine uses a global synonym list and returns documents with matched synonyms. For example, searching for sidewalk also returns documents that contain the word footpath. Searching for footpath also returns documents that contain sidewalk.


Exact Phrase Searching

Add quotation marks (" ") around a phrase to return only documents that contain every word in the phrase, in that order. Stemming is turned off for phrases in quotation marks.

Example: "sign dimensions"


Wildcard Searches

Use a wildcard search to search for alternate forms of a word. A question mark (?) replaces a single character. An asterisk (*) replaces zero or more characters.

Example: ordinanc? zon*

This example finds words such as ordinance or ordinances, and any word that starts with “zon,” such as zone, zoned, or zoning.


Proximity Searches

Use a proximity search to find two words within a set distance of each other in the text. Add a tilde symbol (~)  and a number after the phrase to set the maximum number of words allowed between the two search terms.

Example: "sidewalk repair"~10

This example finds documents where sidewalk and repair appear within 10 words of each other.


Boosting a Term

Use a caret symbol (^) and a number after a term to boost its relevance in a matching document. A higher number gives the term more weight in the search results.

Example: ordinance^4 code

This example ranks documents that contain ordinance higher than documents that only contain code.


Boolean Operators

By default, all search terms are optional, and a document matches if it contains at least one term. Use a plus sign (+) to require a term. Use a minus sign (-) to exclude a term.

Example: code zoning +permit -variance

This search states that:

  • permit must be present (+)

  • variance must not be present (-)

  • code and zoning are optional terms that increase relevance when present

Our search engine also supports AND, OR, and NOT (also written &&, || and !).  Unlike + and -,  these operators can affect more than one term at a time. NOT takes precedence over AND, which takes precedence over OR. Rewriting the  code zoning +permit -variance example with these operators is not as simple as it looks.

Examples:

  • code OR zoning AND permit AND NOT variance: This is incorrect, since zoning becomes a required term.

  • (code OR zoning) AND permit AND NOT variance: This is also incorrect, since at least one of code or zoning becomes required, and the search would be scored differently from the original query.

  • ((code AND permit) OR (zoning AND permit) OR permit) AND NOT variance: This version replicates the logic of the original query correctly, but the relevance scoring no longer resembles the original.


Grouping

Group multiple terms or clauses with parentheses to form sub-queries.

Example: (code OR zoning) AND permit

This example finds documents that contain permit, along with either code or zoning.