MunicodeNEXT uses ElasticSearch 5.5 to perform searches across code, ordinance, and document content types. Most users can simply enter one or more keywords into the search box to find what they're looking for. However, power users may want to be a bit more specific with their searches. ElasticSearch supports the following operators for more advanced, specific searches.
Searches with no operators will default to these settings:
- Keywords - our search engine returns documents with a high frequency of matched keywords. If a search term only includes two keywords (barking dog) then only documents containing both keywords is returned. If a search term includes more than two keywords, only documents matching 75% of the keywords are returned.
- Stemming - all terms will be stemmed by default. For example, searching for park will return parks, parking, parked. (on for e/thing except double quotes)
Synonyms - we leverage a global synonym list and return documents with matched synonyms for all searches. For example, searching for chicken will also return documents containing the term fowl, and vice versa.
Exact Phrase Searching
Adding double quotes around a phrase forces the application to return results containing ALL of the terms present in the phrase. Stemming is turned off when performing an exact phrase query.
Example: "sign dimensions"
Wildcard searches can be run on individual terms, using ? to replace a single character and * to replace zero or more characters.
Example: qu?ck bro*
Proximity searches allow you to specify the distance between terms. The tilde "~" symbol is used along with a number.
Example: "dogs cats"~10 will find documents with dogs AND cats 10 or less words apart from each other.
Boosting a term
By default, all terms are optional as long as one term matches. To provide more control, you may use the following Boolean operators:
quick brown +fox -news
- fox must be present
- news must not be present
- quick and brown are optional - their presence increases relevance.
!) are also supported. However, the effects of these operators can be more complicated than is obvious at first glance.
NOTtakes precedence over
AND, which takes precedence over
OR. While the
-only affect the term to the right of the operator,
ORcan affect the terms to the left and right.
Rewriting the above query using
NOT demonstrates the complexity:
quick OR brown AND fox AND NOT news
- This is incorrect, because
brownis now a required term.
(quick OR brown) AND fox AND NOT news
- This is incorrect because at least one of
brownis now required and the search for those terms would be scored differently from the original query.
((quick AND fox) OR (brown AND fox) OR fox) AND NOT news
- This form now replicates the logic from the original query correctly, but the relevance scoring bears little resemblance to the original.
Multiple terms or clauses can be grouped together with parentheses, to form sub-queries:
Example: (quick OR brown) AND fox
For a more detailed version of this document, please reference: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax.