Searching
SearchBlox supports faceted search, API-based search, and secure search.
Searchblox uses a standard search query format that includes operators and faceted options.
Search Query Syntax
- The SearchBlox query syntax combines Elasticsearch syntax with SearchBlox’s custom syntax.
Operators in Search
| Operator Description | Operator | Example |
|---|---|---|
| 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 Operator | OR | “searchblox server” OR elasticsearch |
| AND Operator | AND | searchblox AND j2ee |
| NOT Operator | NOT | “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
| Field | Description | Example |
|---|---|---|
| title | Title of the document | title: test |
| keywords | Keywords from the document | keywords: search |
| description | Description of the document | description: "This is test" |
| url | URL of the document | url: "https://www.searcblox.com" |
| content | content of the document | content: searchblox content |
| contenttype | File type of the document | contenttype: pdf |
| meta data | custom fields index from html, files or databases | author: Stephan |
| Grouping | combination 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 lets you use wildcard searches with single or multiple characters.
- Use
?for a single-character wildcard and*for multiple characters. - The
?wildcard matches only one character. - Example: To match
textortest, usete?t. - The
*wildcard matches zero or more characters. - Example: To match
test,tests, ortester, usetest*. - You can also place wildcards in the middle of a word, like
te*t.
Fuzzy Search
- SearchBlox supports fuzzy search, which finds results even when words are misspelled.
- To use it, add a ~ at the end of a single word.
- Example: Searching roam~ will also match words like foam and roams.
- For multiple words, add the fuzzy operator to each word separately.
- Example: international~ earth~ day~ performs a fuzzy search on all three words.
Proximity Search
- SearchBlox supports proximity search, which finds words that appear near each other.
- To use proximity search, put a ~ at the end of a phrase and specify the distance between words.
- Example: To find “searchblox” and “j2ee” within 10 words of each other, use:
"searchblox j2ee"~10
Exact Search or Phrase Search
- To find documents with an exact phrase, enclose the phrase in double quotes.
- Example: To search for Old is gold, use: "Old is gold"
Boolean Operators
- Boolean operators** combine search terms using logic.
- SearchBlox supports:
AND,+,OR,NOT, and-. - Operators
AND,OR, andNOTmust be in ALL CAPS.
OR Operator
- The OR operator is the default in the SearchBlox Search API.
- It finds documents if either of the terms or phrases exists.
- Example: To search for documents containing either "searchblox server" or elasticsearch, use: "searchblox server" OR elasticsearch.
- A simple query like searchblox j2ee also returns documents containing either term.
AND Operator
- The AND operator finds documents where both terms appear in the text.
- Example: To search for documents containing searchblox and j2ee, use: searchblox AND j2ee.
NOT Operator
- The NOT operator excludes documents that contain the term following NOT.
- Example: To find documents containing "searchblox server" but not j2ee, use: "searchblox server" NOT j2ee.
- The NOT operator cannot be used alone; a query like NOT "searchblox server" will return no results.
Plus Operator "+"
- The + (required) operator ensures that the term after + must exist in a document.
- Example: To search for documents that must include searchblox and may include j2ee, use: +searchblox j2ee.
Minus Operator "-"
- The - (minus) operator excludes documents containing the term after -.
- Example: To find documents containing "searchblox server" but not j2ee, use: "searchblox server" -j2ee.
*Fielded Search** - SearchBlox supports fielded search, allowing searches within a specific field.
- By default, searches are performed on content, title, description, and other mapped custom fields.
- To search a specific field, use the syntax: fieldname:searchterm.
- Examples:
keywords:news
title:world
url:"http://www.bbc.com" - For
urlfield, enclose the URL in double-quotes. - Fielded search works on standard fields and custom fields.
- The following fields can be used in fielded search queries:
| Fields | Default | Description | Example |
|---|---|---|---|
| content | Yes | Document content | content:test |
| keywords | Yes | Document keywords | keywords:news |
| title | Yes | Document title | title:"world news" |
| description | Yes | Document description | description:world |
| url | No | Document URL | url:"http://edition.cnn.com" |
| contenttype | No | Document format | contenttype:pdf contenttype:word |
| language | No | ar – 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 – Turkish | language:en |
Grouping
- SearchBlox supports using parentheses () to group clauses and create sub-queries.
- Grouping allows you to control Boolean logic in a query.
- Example: To search for either
searchbloxorserver, and alsoj2ee:
(searchblox OR server) AND j2ee - Fielded search can also be grouped with Boolean operators for complex queries:
+travel +world +(title:"news")
(world AND travel) OR keywords:news
((world AND travel) OR keywords:news) AND cnn
Default AND/OR operation
- In the SearchBlox API, when multiple search terms are used, the default operator is OR.
- You can change the default to AND by using the parameter &default=AND.
- In faceted search, &default=AND ensures that multiple terms are combined with the AND operator.
- To learn more on this parameter read: Search Parameters
Using Special Characters in Search
- SearchBlox uses sb_analyzer by default, which ignores special characters during indexing, though they can appear in context.
- To retain special characters for search, you can change the analyzer.
- Characters that can be used directly without an escape character: @ # $ ^ & - + = | " , . ? ( ) *
- Example: test@
- Characters that require an escape character: ~ { } ! : < > _ [ ] / \ %
- Example: test%
- The fuzzy search operator ~ cannot be used directly or with an escape character; enclose the term in double quotes for search.
- Example:
"test~nest" - For more on search analyzers and handling special characters, refer: Analyzers in SearchBlox
Sample Search Queries
| Search Query | Search Results |
|---|---|
searchblox test | If default=OR, contain the words searchblox or test. If default=AND, contain both words. |
enterprise (contenttype:word OR contenttype:excel OR contenttype:msg) | Contain the word enterprise and have file types Word, Excel, or .msg. |
"Enterprise Search" | Contain the exact phrase Enterprise Search. |
Enterprise AND Search | Contain both words Enterprise and Search. |
("Enterprise" OR "Search") AND "SearchBlox" | Contain the word Enterprise or Search and also 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. Wellness is weighted twice as strong as other terms.. |
+Enterprise +Search | Must contain both words Enterprise and Search. |
Enterprise Search +SearchBlox | Contain Enterprise or Search and must contain SearchBlox. |
+(Enterprise Search) +SearchBlox | Contain either Enterprise or Search and must contain SearchBlox.` |
SearchBlox -test | Contain SearchBlox but not the word test. |
Updated 25 days ago
