AutoComplete

SearchBlox Indexed Data Based AutoComplete

  • Suggestions can be fetched from content or title 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:
18111811
  • 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:
18191819
  • Response of Title field suggestions:
17891789

🚧

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.

ParameterDescription
qQuery
limitNumber 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:
18211821

🚧

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.

queryquery
cnameThe cname value has to be searchlogs for fetching suggestions from querylogs
limitNumber 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.
801801
  • The source of suggestions can be selected in Search Settings as mentioned in the previous sections.
17821782

AutoComplete Parameters

SearchBlox ParametersDescriptionGSA Equivalent
queryPartial query for which the suggestions are displayedq
limitThe maximum number of results that the Auto-complete API should return.
Default value is 10.
max
colcollection numbersite
cnamecollection namesite

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:

  1. Go to <SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/ROOT/WEB-INF/
  2. Make changes in mapping.json or jdbc.json or csv.json depending on the collection from which the field is used for AutoComplete.
  3. Give the following mapping in the custom field:
"author": {
        "type": "completion"
      },
  1. Clear and reindex the collection with the field.
  2. Select Autocomplete Field as Title or Content.
  3. 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

  1. Go to <SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/ROOT/WEB-INF/
  2. Make changes in mapping.json or jdbc.json or csv.json depending on the collection from which the field is used for AutoSuggest.
  3. Give the following mapping in the description field:
"description": {
         "type": "text",
        "store": true,
        "analyzer": "sb_analyzer"
        "fields": {
          "desc": {
            "type": "completion"
          }
        }
      },
  1. Clear and reindex the collection.
  2. Select Autocomplete Field as Title or Content.
  3. 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

  1. Go to <SEARCHBLOX_INSTALLATION_PATH>/searchblox/webapps/ROOT/WEB-INF/
  2. 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
  3. Give the following mapping in the description field and test field:
"description": {
         "type": "text",
        "store": true,
        "analyzer": "sb_analyzer"
        "copy_to": "test"
              },
        "test": {
            "type": "completion"
            },
  1. Clear and reindex the collection.
  2. Select Autocomplete Field as Title or Content.
  3. 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
602602

What’s Next