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.
This article will outline the modifiers and operators supported by ElasticSearch that can be used for more advanced, specific searches.
Skip to Topics in This Article
Searches with no operators will default to the following 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 are returned. If a search term includes more than two keywords, only documents matching 75% of the keywords are returned.
- Stemming: All search terms will be stemmed by default, except for those included in quotation marks. For example, searching for
parkwill also return results for
- Synonyms: We leverage a global synonym list and return documents with matched synonyms for all searches. For example, searching for
chickenwill also return documents containing the term
fowl, and vice versa.
Exact Phrase Searching
Adding quotation marks (" ") 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.
Wildcard searches, or searches for alternative forms of a word, can be run on individual terms using a question mark (?) to replace a single character and an asterisk (*) to replace zero or more characters.
Proximity searches allow you to specify the distance between terms within the text. The tilde (~) symbol is used along with a number to designate how far apart words should be from each other. The example search below will find documents that include the words dogs and cats with 10 or fewer words between.
Boosting a Term
You can boost the relevance of a term in a matching document by using the carat (^) symbol and a number.
By default, all search terms are optional as long as one term matches. To provide more control, you may use Boolean operators
A search for
quick brown +fox -news states that:
- fox must be present (+)
- news must not be present (-)
- quick and brown are optional (their presence increases relevance)
The familiar operators
NOT (also written
!) are also supported. However, the effects of these operators can be more complicated than is obvious at first glance.
NOT takes precedence over
AND, which takes precedence over
OR. While the
- only affect the term to the right of the operator,
OR can 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 brown is now a required term.
(quick OR brown) AND fox AND NOT news
This is incorrect because at least one of quick or brown is 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 with parentheses, to form sub-queries.
(quick OR brown) AND fox
CommentsLet us know what was helpful or not helpful about the article.
Please sign in to leave a comment.