AutoSuggest
SearchBlox Indexed Data Based Autosuggest
- Suggestions can be fetched from
content
ortitle
field of indexed data - Content-Based Autosuggest fetches suggestions from the content indexed. If the user wants to enable this in the search, then the selection has to be made in Search Settings as shown:
- Title-Based Autosuggest fetches suggestions from the title field indexed. If the user wants to enable this in the search, then the selection has to be made in Search Settings as shown:
- SearchBlox provides suggestions of terms from indexed content or title in JSON format limited based on collections in AutoSuggest Servlet as shown:
http://localhost:8080/searchblox/servlet/AutoSuggest?q=hello&col=1&limit=10
or
http://localhost:8080/searchblox/servlet/AutoSuggest?q=hello&cname=test&limit=10
where q is the query string, col is the collection number, cname is the collection name and limit is the number of auto-suggest values to be displayed.
Important Information
- Kindly note that it is mandatory to select the Autocomplete field in search settings for the suggestions to be fetched from title or content in AutoSuggest Servlet mentioned in the preceding section.
Parameter | Description |
---|---|
q | Query |
col | Collection Number Absence of the collection field will fetch suggestions from all collections |
cname | Collection Name Absence of the collection field will fetch suggestions from all collections |
limit | Number of suggestions per page |
SearchBlox Query-Based Autosuggest
- Suggestions can be fetched from past queries made by the user.
- Query-Based Autosuggest fetches suggestions from the past queries logged in the querylogs index. If the user wants to enable this in the search, then the selection has to be made in Search Settings as shown:
- SearchBlox can also fetch suggestions from past queries using the collection name
searchlogs
in AutoSuggest servlet as shown:
http://localhost:8080/searchblox/servlet/AutoSuggest?q=hello&cname=searchlogs&limit=10
Important Information
It is not mandatory to select the autosuggest field as the query in search settings as providing the cname as searchlogs will fetch suggestions from querylogs irrespective of the selection made in search settings Autocomplete field.
q | query |
cname | The cname value has to be searchlogs for fetching suggestions from querylogs |
limit | Number of suggestions per page |
AutoSuggest in Faceted Search
- Autosuggest/Autocomplete is enabled by default in faceted search.
- This feature can be disabled by making the change in
<SEARCHBLOX_INSTALLATION_PATH>/webapps/searchblox/plugin/facet.js
by providing false as value for the field showAutoSuggest as shown:
"showAutoSuggest": false,
- The number of autosuggest values in default faceted search would be 5.
- The source of suggestions can be selected in Search Settings as mentioned in the previous sections.
AutoSuggest Servlet Parameters
SearchBlox Parameters | Description | GSA Equivalent |
---|---|---|
q | Partial query for which the suggestions are displayed | q |
limit | The maximum number of results that the Auto-suggest servlet should return. Default value is 10. | max |
col | collection number | site |
cname | collection name | site |
Custom Autosuggest
- In SearchBlox it is possible to configure AutoSuggest for specific fields other than content or title or querylogs.
- These specific fields could be SearchBlox fields or custom fields indexed in SearchBlox.
Custom Autosuggest for Custom Fields
Autosuggest or autocompletion can be enabled for a custom field using the following steps:
- Go to
<SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/searchblox/WEB-INF/
- Make changes in mapping.json or jdbc.json or csv.json depending on the collection from which the field is used for AutoSuggest. To learn more on mapping and collections associated read: Mapping Files for Collections
- Give the following mapping in the custom field:
"author": {
"type": "completion"
},
- Clear and reindex the collection with the field.
- Select Autocomplete Field as Title or Content.
- Check the autosuggestions with following URL and params in AutoSuggest Servlet
http://localhost:8080/searchblox/servlet/AutoSuggest?q=speaker&type=custom&field=author
Custom Autosuggest for SearchBlox Fields
Custom Autosuggest can be used for SearchBlox fields as in the following steps:
Let us consider that autosuggest is to be used for the description
field, it can be done in two ways:
Providing Subfield within the Actual Field
- Go to
<SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/searchblox/WEB-INF/
- Make changes in mapping.json or jdbc.json or csv.json depending on the collection from which the field is used for AutoSuggest. To learn more on mapping and collections associated read: Mapping Files for Collections
- Give the following mapping in the
description
field:
"description": {
"type": "text",
"store": true,
"analyzer": "sb_analyzer"
"fields": {
"desc": {
"type": "completion"
}
}
},
- Clear and reindex the collection.
- Select Autocomplete Field as Title or Content.
- Autosuggestions can be fetched based on description field using
description.desc
as in the following URL
http://localhost:8080/searchblox/servlet/AutoSuggest?q=y&type=custom&field=description.desc
Copying to a New Field
- Go to
<SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/searchblox/WEB-INF/
- Make changes in mapping.json or jdbc.json or csv.json depending on the collection from which the field is used for AutoSuggest. To learn more on mapping and collections associated read: Mapping Files for Collections
- Give the following mapping in the
description
field andtest
field:
"description": {
"type": "text",
"store": true,
"analyzer": "sb_analyzer"
"copy_to": "test"
},
"test": {
"type": "completion"
},
- Clear and reindex the collection.
- Select Autocomplete Field as Title or Content.
- Autosuggestions can be fetched based on the description field using field
test
as in the following URL:
http://localhost:8080/searchblox/servlet/AutoSuggest?q=y&type=custom&field=test
Updated almost 3 years ago
What’s Next