AutoComplete
SearchBlox Indexed Data Based AutoComplete
- Suggestions can be fetched from
content
ortitle
field of indexed data - Content-Based Autocomplete 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 Autocomplete 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:
- Response of Title field suggestions:
- SearchBlox provides suggestions of terms from indexed content or title, based on collections in Autocomplete API as shown:
https://localhost:8443/rest/v2/api/autocomplete?limit=5&query=news
where query is the query string 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 the title or content in Autocomplete API mentioned in the preceding section.
Parameter | Description |
---|---|
q | Query |
limit | Number of suggestions per page |
SearchBlox Query-Based AutoComplete
- Suggestions can be fetched from past queries made by the user.
- Query-Based Autocomplete 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 Autocomplete servlet as shown:
https://localhost:8443/rest/v2/api/autocomplete?limit=5&query=new
Important Information
It is not mandatory to select the autocomplete 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.
query | query |
cname | The cname value has to be searchlogs for fetching suggestions from querylogs |
limit | Number of suggestions per page |
- Autocomplete Search for Querylogs(cname for Querylogs is searchlogs)
JSON Reponse:
["news","news analysis and","news and features","news and video","news breaking news"]
Autocomplete in Faceted Search
- Autocomplete is enabled by default in faceted search.
- This feature can be disabled by making the change in
<SEARCHBLOX_INSTALLATION_PATH>/webapps/ROOT/search/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.
AutoComplete Parameters
SearchBlox Parameters | Description | GSA Equivalent |
---|---|---|
query | Partial query for which the suggestions are displayed | q |
limit | The maximum number of results that the Auto-complete API should return. Default value is 10. | max |
col | collection number | site |
cname | collection name | site |
Custom AutoComplete
- In SearchBlox it is possible to configure AutoComplete for specific fields other than content or title or querylogs.
- These specific fields could be SearchBlox fields or custom fields indexed in SearchBlox.
Custom Autocomplete for Custom Fields
Autocompletion can be enabled for a custom field using the following steps:
- Go to
<SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/ROOT/WEB-INF/
- Make changes in mapping.json or jdbc.json or csv.json depending on the collection from which the field is used for AutoComplete.
- 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 the following URL and params in AutoComplete API
https://localhost:8443/rest/v2/api/autocomplete?query=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/ROOT/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.
- 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
https://localhost:8443/rest/v2/api/autocomplete?limit=5&query=cnn&col=1&field=description.desc
Copying to a New Field
- Go to
<SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/ROOT/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:
https://localhost:8443/rest/v2/api/autocomplete?limit=5&query=cnn&cname=test
Updated about 2 years ago