In this article
You need to use Boolean operators in the search field when you write search expressions. The Boolean operators combine search words in your expression.
Apostrophes
Operators are sensitive to apostrophes in multiple ways.
Searching with or without an apostrophe will yield different results.
For example:
Trader Joes
Trader Joe's
Using different types of apostrophe (' or ‘) will yield different results.
For example:
Trader Joe's
Trader Joe‘s
Logical AND
The AND operator will combine two (or more) search words. For example if you want to search for posts containing both of the car manufacturers Audi and Mercedes, your search expression will be audi AND mercedes. Only posts where both words occur will be returned in the search result. Note that the order in which the words appear, and their distance apart, will not be taken into consideration.
Logical OR
The OR operator will return posts where any of the given search words are represented. For example if you want to search for posts that mention either of the phone companies Orange or Vodafone, your search expression will be orange OR vodafone. Any posts containing either Orange or Vodafone will then be returned.
Logical NOT
The NOT operator is used to exclude posts that contain the specified search words. For example if you want to search for all posts that mention iPhone, but exclude posts that mention Samsung, your search expression would be iphone AND NOT samsung.
Logical operators are always written in UPPER CASE. To make your search expressions easier to read we suggest that you always write your search words in lower case. For example both “AUDI AND MERCEDES” and “audi AND mercedes” will return the same results, but the latter is easier to read.
Grouping the expressions using parenthesis
The search expression can be grouped by parenthesis as one logical entity, which can be further connected with other logical entities by Boolean operators. For example, (hotel AND lodging) AND (clean OR cleaned). This expression will provide results which contains both hotel and lodging with clean or cleaned.
Parenthesis are very useful and can be used when nesting logic blocks together. In the example above we have a = (hotel AND lodging) and b = (clean OR cleaned), but if we add ((hotel AND lodging) AND (clean OR cleaned)) AND NOT (dirt OR dirty) we are creating c = (dirt OR dirty) to exclude dirty hotels and lodgings.
To make this easier we can think of this as (a OR b) AND NOT c.
Quoted search
When we have keywords that occur together in an exact order, using quoted search makes it possible to capture this. For example, say we are looking for check in at a hotel. You can search for ((check OR checking) AND in), but this would yield too many results. The more elegant solution would be to use “check in” OR “checking in” to preserve both recall and precision.
Note: Microsoft Word uses smart quotes,
Proximity search
You can use the proximity operator (~) to specify a maximum number of words between your search words. If you want to find information about clean rooms you would use the proximity search. Your search expression could then be "room clean"~3 . In this example the expression will return only those posts where there are a maximum of three words between clean and room.
For example, “The room was clean”, “The room was very clean and nice” and “The room was bright and clean” are all valid results.
One important thing to be aware of is that the proximity search will also find the reverse order of your query, but the reversal will count as two words. This means that "room clean"~3 also finds "clean room"~1. This means that “We got a clean bright room” is also a valid result, but not “We got a clean and nice room”.
You will need to test the maximum number to use with your proximity indicator, to see which number produces clean results and which starts to bring in unwanted results. Proximity operator can also be used when there are more than two keywords in the double quotation mark.
Wild card search
The wildcard operators (* and ?) ensure that all words that start or end with the preceding or following text characters will be captured. For example, categor* will find words such as category, categories, categorisation and categorization, and *common will find words such as common and uncommon. Wild cards do not work within quotation marks.
The ? can be used to wildcard a single character in a word. For example both Categorization in US English and Categorisation in UK English could be captured by using the keyword categori?ation.
Fuzzy search
Fuzzy search returns more search results by allowing some "errors" in the search term. For example, communication~ will find words like communication, communications, comunication, comuunication etc. When doing fuzzy search, the tilde sign (~) must follow immediately after a term. Optionally you can specify how many characters are allow to be wrong in the term. For example, communication~1 allows one character to be wrong, while communication~2 allows two mistakes. If there is no parameter specified, the fuzzy search will allow two characters to be wrong by default.
Fuzzy search is more useful for long keywords.
Regular expressions
Regular expressions can be used as part of the expressions. Model Builder supports regular expressions through Lucene. Go to the link below for help on writing these expressions.
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#regexp-syntax
Contact your Account Manager if you want to learn more from our Analytics team.
Exact search
The content_exact search term allows us to search for something exactly as it is written, with punctuation, hyphens or other symbols, which the normal search does not provide. For example searching for ”off-white” will give you results that contains off-white, but also off and white together. Using content_exact:”off-white” will provide only results that contain off-white. The table below lists some query and result examples.
| Query | Example results from standard search | Example results from content_exact search |
|---|---|---|
| W210 | W210, W-201, DSC-W210, W - 210 | W210 |
| wi-fi | WiFi, Wi, Fi, Wi-Fi | Wi-Fi, wi-fi |
| SX | SX210, 180SX, 40S-X | SX |
| oleary | OLeary, O'Leary | oleary |
| SD500 | SD-500, SD500, SD 500, SD 500s | SD500 |
| 42 | 42, 6.42, 42kg | 42 |
Table 1 Results from standard search and content_exact search
Special characters
Characters that are not alphanumeric cannot be searched for like normal characters. However they can be used when prefixed with content exact.
Example: content_exact:$, content_exact:50%
Wild cards can also be used with the exact search like this: content_exact:$*
Some characters are special and have been reserved by the search system. They can still be searched for, but they have to be escaped. They are escaped if they have backslash (\) before them or double quotation marks ("") around them.
Examples: content_exact:\+, content_exact:"+"
| Special characters | Special characters | |
|---|---|---|
| + | ) | “ |
| - | { | ~ |
| && | } | * |
| || | [ | ? |
| ! | ] | : |
| ( | ^ | / |
Table 2 List of special characters that must be escaped
Term counter
You can search for the number of terms that occur in a response using content_termcount. It is also possible to do a range lookup. This type of filtering can be useful when you have lots of responses with only a few words, typically one to four that you want to filter out. For example: content_termcount:1 will find any response that has exactly one term.
Range search example: content_termcount:[1 TO 4] will find any response that has from one to four words in it.
Length
Searching for the number of characters used in a response can be done with content_length. As with termcount, this can also be range lookup. For example: content_length:3 will find all responses that have exactly three characters, and content_length:[1 TO 5] will find all responses that have one to five characters.
References and Keywords in Model Builder search expressions
Model Builder offers a range of fields that you can use to better refine your search queries. The following lists all these fields and gives examples of how they will impact your search results.
| Field name | Explanation | Examples of usage |
|---|---|---|
| subject | Performs a search that looks for matching terms in the subject of a comment. The subject stores the survey question label from Forsta Plus. |
subject:why subject:"Why did you give us that score?" |
| date | Performs a search with date restriction. |
date:"2020-01-01" (will only give results from January 2020). date:[2020-01-01 TO 2020-02-01] (will only give results between January 1st 2020 and February 1st 2020) |
| time | Limits your search to a specific timestamp. | android AND time:[00:00:00 TO 01:00:00] (will give you all talk about Android between midnight and 01:00) |
| content_exact | The exact version of the content field. This will give stricter results. |
content_exact:"iPhone7+" content_exact:"$500" |
| language | Limit your search to a specific language. Uses standard language unicodes. |
language:en language:se |
| projectid | Enables you to use the Forsta Plus projectid (survey p-number) in your query. | projectid:p189794685 |
| content_termcount | Searches for a specific number of terms or a range of terms. | content_termcount:1 (will only give results that has one word in the response). content_termcount:[1 TO 5] (will give results that has from one to five words in the response). |
| content_length | Searches for a response with a specific number of characters or a range of characters. | content_length:1 (will only give results that has one character in the response). content_length:[1 TO 5] (will give results that has from one to five characters in the response). |
| content_casing | Searches the content for a word or phrase with consideration to the capitalization of the letters. |
"Grace" will match Grace and grace content_casing: "Grace" will match only Grace |
| textfieldid | Used to limit a search to specific question IDs if it is a survey or a table column in a custom data set. |
Table 3 Searchable fields quick reference