SearchBlox allows you to perform faceted, API-based and security-enabled search.

  • [Faceted Search](🔗)

  • [Search API](🔗)

  • [Secure Search](🔗)

SearchBlox supports an industry-standard search query syntax with operators and faceted search.

## **Search Query Syntax**

  • SearchBlox query syntax is a combination of Elasticsearch query syntax and custom query syntax.

## **Operators in Search**

Operator DescriptionOperatorExample
Wildcard Operator* (Asterisk Operator) ? (Question Operator)`test*` `te?t`
Fuzzy Search Operator~ (Tilde Operator)`roam~`
Proximity~10 (Tilde with numeric operators)`“searchblox j2ee”~10`
Exact Search Operator"" (Double Quotes operator)`“Old is gold"`
OR OperatorOR`“searchblox server” OR elasticsearch`
AND OperatorAND`searchblox AND j2ee`
NOT OperatorNOT`“searchblox server” NOT j2ee`
Plus Operator+ (Plus Operator)`+searchblox j2ee`
Prohibit Operator- (Minus Operator)`"searchblox server” -j2ee`
Fielded Search Operator: (Colon Operator)`keywords:news`
Escape Operator\`test\~`

## **Fielded Search**

titleTitle of the document`title: test`
keywordsKeywords from the document`keywords: search`
descriptionDescription of the document`description: "This is test"`
urlURL of the document`url: ""`
contentcontent of the document`content: searchblox content`
contenttypeFile type of the document`contenttype: pdf`
meta datacustom fields index from html, files or databases`author: Stephan`
Groupingcombination of SearchBlox and custom fields can be provided in fielded search`title: test AND author: Stephen AND keywords:search` `+travel +world +(title:news)` `((world AND travel) OR keywords:news) AND cnn`

### Wildcard Search

  • SearchBlox supports single and multiple wildcard character search.

  • To perform a single character wildcard search, use the `?` symbol. To perform a multiple character wildcard search, use the `*` symbol.

  • The single character wildcard search looks for terms that match with the single character replaced.

  • To search for `text` or `test` you can use the search query: `te?t`

  • Multiple character wildcard searches look for 0 or more characters.

  • To search for `test`, `tests`, or `tester`, you can use the search query: `test*`

  • You can also use a wildcard character in the middle of a term. `te*t`

### Fuzzy Search

  • SearchBlox supports fuzzy search. Fuzzy search can also be referred to as an approximate search and can fetch results even for incorrect spelling.

  • To perform a fuzzy search, use the tilde `~` symbol at the end of a single word term in the search query.

  • To search for a term similar in spelling to `roam`, use the fuzzy search query: `roam~` This search will find terms like `foam` and `roams`.

  • If you want a fuzzy search for more than one term, fuzzy search operator has to be used separately for each term,

  • To perform a fuzzy search on `International earth day`, use the search query: `international~ earth~ day`

### Proximity Search

  • SearchBlox supports proximity search which allows you to find words within a specific distance.

  • To do a proximity search, use the tilde `~` symbol at the end of a phrase.

  • To search for “searchblox” and “j2ee” within 10 words of each other in a document use the search query: `“searchblox j2ee”~10`

### Exact Search or Phrase Search

  • To find documents with the exact phrase, the search query has to be enclosed within double quotes.

  • To search the phrase `Old is gold`, use the search query: `“Old is gold"`

### Boolean Operators

  • Boolean operators allow search query terms to be combined through logic operators.

  • SearchBlox supports `AND`, `+`, `OR`, `NOT` and `-` as Boolean operators

  • Boolean operators `AND`, `OR` and `NOT` must be ALL CAPS.

**OR Operator**

  • The `OR` operator is the default operator in SearchBlox Search API.

  • The OR operator finds documents if either of the terms or phrases exists in a document.

  • To search for documents that contain either the phrase `searchblox server` or just the term `elasticsearch` use the below search query: `“searchblox server” OR elasticsearch`

  • The following search query finds documents with either terms: `searchblox j2ee`

**AND Operator**

  • The `AND` operator finds documents where both terms exist anywhere in the text of the document.

  • To find documents that contain `searchblox` and `j2ee` use the following query: `searchblox AND j2ee`

**NOT Operator**

  • The `NOT` operator excludes documents that contain the term after NOT.

  • To search for documents that contain “searchblox server” but not “j2ee”, use the search query: `“searchblox server” NOT j2ee`

  • The `NOT` operator cannot be used with just one term.

  • The following search will return no results: `NOT “searchblox server”`

**Plus Operator "+"**

  • The `+` or required operator requires the term after the `+` symbol to exist somewhere in the field of a single document.

  • To search for documents that must contain `searchblox` and may contain `j2ee` use the search query: `+searchblox j2ee`

**Minus Operator "-"**

  • The `-`, or minus operator, excludes documents that contain the term after the `-` symbol.

  • To search for documents that contain `“searchblox server”` but not `j2ee` use the search query: `"searchblox server” -j2ee`

### Fielded Search

  • SearchBlox supports fielded search where you can search within a specific field.

  • The default search is performed on content, title, description, and other custom fields that have been mapped to the content.

  • This search can be made specific using fielded search.

  • Fielded search requires you to give the field name followed by a colon `:`, and then the search term you are looking for.

  • Examples: `keywords:news` `title:world` `url:""`

  • When performing fielded search on url field, the url has to be enclosed in double-quotes.

  • You can perform fielded search on standard fields as well as custom fields.

The following fields that can be used for fielded search queries:

contentYesDocument contentcontent:test
keywordsYesDocument keywordskeywords:news
titleYesDocument titletitle:"world news"
descriptionYesDocument descriptiondescription:world
urlNoDocument URLurl:""
contenttypeNoDocument formatcontenttype:pdf contenttype:word
languageNoar – Arabic bn – Bengali zhcn - Chinese cs – Czech da – Danish nl – Dutch en – English es – Estonian fi – Finnish fr – French de – German el – Greek gu – Gujarati iw – Hebrew hi – Hindi hu – Hungarian it – Italian ja – Japanese kn – Kannada ko – Korean lv – Latvian lt – Lithuanian mal – Malayalam no – Norwegian pl – Polish pt – Portuguese ro – Romanian ru – Russian sk – Slovak sl – Slovenian es – Spanish sv – Swedish ta – Tamil te – Telugu th – Thai tr – Turkishlanguage:en

### Grouping

  • SearchBlox supports using parentheses to group clauses to form sub-queries.

  • Grouping is useful for users who want to control the Boolean logic for a query.

  • To search for either `searchblox` or `server`, and `j2ee`, use the query: `(searchblox OR server) AND j2ee`

  • You can also group fielded search with Boolean operators to form complex queries like: `+travel +world +(title:"news")` `(world AND travel) OR keywords:news` `((world AND travel) OR keywords:news) AND cnn`

### Default AND/OR operation

  • In Search API when more than one search term is used, the default operator used is `OR`.

  • We support a special parameter `&default=AND` which can change this query to `AND`.

  • In faceted search we use `&default=AND` as a standard to make `AND` search with multiple terms.

  • To learn more on this parameter read: [Search Parameters](🔗)

## **Using Special Characters in Search**

SearchBlox uses the sb_analyzer by default. [sb_analyzer](🔗) ignores the special characters; however, the special characters would appear in context. We strip off the special characters while indexing. If you want to retain the special characters for search, you can change the analyzer.

The following characters can be used directly without escape character:


eg: test@

The following characters require escape character preceding it:

~,{ },!,:, < >,_,[] ,/ \ ,%

eg: test\%

Fuzzy search operator i.e., tilde ~ operator cannot be used directly or using an escape character. The search term with characte~r can be enclosed in double-quotes for search.

eg: "test~nest"

To learn about search analyzers and how to handle special characters visit: [Analyzers in SearchBlox] (doc:elasticsearch-custom-analyzers)

## **Sample Search Queries**

Search QuerySearch Results
`searchblox test`If default=OR, contain the words `searchblox` or `test`. If default=AND, contain the words `searchblox` or `test`.
`enterprise (contenttype:word OR contenttype:excel OR contenttype:msg)`contain the word `enterprise` and have the file types as Word, Excel, or .msg.
`"Enterprise Search"`contain the exact expression `Enterprise Search`.
`Enterprise AND Search`contain the words `Enterprise` and `Search`.
`("Enterprise" OR "Search") AND "SearchBlox"`contain the word `Enterprise` or `Search` and the word `SearchBlox`.
`SearchBlox NOT test`contain the word `SearchBlox` but **not** the word `test`.
`(Wellness^2.0 OR help) AND learning`contain `Wellness` or `help` and `learning`. The occurrence of `Wellness` is twice as strong rated as other terms.
`+Enterprise +Search`contain the words `Enterprise` and `Search`.
`Enterprise Search +SearchBlox`contain the word `Enterprise` or `Search` and the word `SearchBlox`.
`+(Enterprise Search) +SearchBlox`contain either `Enterprise` or `Search` and `SearchBlox`
`SearchBlox -test`contain the word `SearchBlox` but **not **the word `test`.