Returns autosuggest information for a specified prefix that is used to autocomplete word candidates in searches. The maximum number of results returned is based on the value you specify for the
The required syntax is in bold.
- | typeahead
- Syntax: prefix=<string>
- Description: The full search string to return
- Syntax: count=<int>
- Description: The maximum number of results to return.
- Syntax: collapse=<bool>
- Description: Specify whether to collapse a term that is a prefix of another term when the event count is the same.
- Default: true
- Syntax: endtimeu=<int>
- Description: Set the end time to N seconds, measured in UNIX time.
- Default: now
- Syntax: index=<string>
- Description: Search the specified index instead of the default index.
- Syntax: max_servers=<int>
- Description: Specify the maximum number of indexers or remote search peers to be used in addition to the search head for
typeaheadsearches. If the
max_serversargument is not specified, the default value is
2, which means Splunk software uses two search peers in addition to any search heads.
- Default: 2
- Syntax: max_time=<int>
- Description: The maximum time in seconds that the
typeaheadcan run. If
max_time=0, there is no limit.
- Default: 1 second
- Syntax: starttimeu=<int>
- Description: Set the start time to N seconds, measured in UNIX time.
- Default: 0
- Syntax: use_cache = <boolean>
- Description: Specifies whether the
typeaheadcache will be used if
use_cacheis not specified in the command line or endpoint. When
use_cacheis turned on, Splunk software uses cached search results when running
typeaheadsearches, which may have outdated results for a few minutes after you make changes to .conf files. For more information, see Typeahead and .conf file updates.
- Default: true or 1
typeahead command is a generating command and should be the first command in the search. Generating commands use a leading pipe character.
typeahead command can be targeted to an index and restricted by time.
When you run the
typeahead command, Splunk software runs internal
typeahead searches and extracts data from indexes, configurations, and search histories. This information is used to autocomplete word candidates when users type commands in the Search bar in Splunk Web. The
typeahead command extracts data from these sources:
- Indexing field names from indexes.
- Settings in configuration files, such as props.conf and savedsearches.conf.
- The search history from previous searches in Splunk Web.
The impact of typeahead on search results
typeahead command returns the most common terms found in indexed data with the given prefix. If you use the
typeahead command with the default settings, the command may not return all search results or the correct search results in the following cases:
- The time to complete the search takes longer than the value specified by the
max_timeargument, which is 1 second, by default.
- Data is indexed on a server that is not randomly chosen, resulting in the exclusion of its data from the search results. This can happen when the value of
max_serveris less than the number of indexers, for example, if
max_serveris set to the default, which is
2, but there are actually 3 indexers.
In addition, the
typeahead command may not return all of the search results if the
count argument is set lower than the actual number of results. For example, if the
count argument is set to
typeahead command returns only the top 10 results, even though more results could actually be returned.
Set the number of additional search peers used in a typeahead job
max_servers argument is designed to minimize the workload impact of running
typeahead search jobs in an indexer clustering environment. For load balancing, the selection of additional search peers for typeahead is random.
A setting of
0 removes all limits, causing all available search peers to be used for typeahead search jobs.
The default for the
max_servers argument is controlled by the
max_servers setting in
Typeahead and .conf file updates
typeahead command uses a cache to run fast searches at the expense of accurate results. As a result, sometimes what is in the cache and shows up in
typeahead search results may not reflect recent changes to .conf files. This is because it takes 5 or 10 minutes for the cached data to clear, depending on the performance of the server. For example, if you rename a
sourcetype in the
props.conf file, it may take a few minutes for that change to display in
typeahead search results. A
typeahead search that is run while the cache is being cleared returns the cached data, which is expected behavior.
If you make a change to a .conf file, you can wait a few minutes for the cache to clear to get the most accurate and up-to-date results from your
typeahead search. Alternatively, you can turn off the
use_cache argument to clear the cache immediately, which fetches more accurate results, but is a little slower. After you manually clear the cache, you should see the changes to your .conf file reflected in your results when you rerun the
For more information, see Rename source types in the Splunk Cloud Platform Getting Data In manual.
Typeahead and tsidx bucket reduction
typeahead searches over indexes that have undergone tsidx bucket reduction will return incorrect results.
For more information see Reduce tsidx disk usage in Managing indexers and clusters of indexers.
Example 1: Return typeahead information for source
When you run a
typeahead search, Splunk software extracts information about field definitions from indexes, configurations, and search histories, and displays the relevant information for the specified prefix. For example, say you run the following search for the
source prefix against the main index:
| typeahead index=main prefix="source" count=3
typeahead command searches the index and shows you what is visible to your users as autocomplete suggestions when they start to type
source in their searches in Splunk Web. The results look something like this:
Example 2: Return typeahead information for saved searches
You can also run
typeahead on saved searches. For example, say you run this search:
|typeahead prefix="savedsearch=" count=3
The results look something like this, which tells you what your users see as autocomplete suggestions when they start to type
savedsearch in the Search bar in Splunk Web.
|savedsearch="Errors in the last 24 hours"||5||true|
|savedsearch="Errors in the last hour"||2||true|
Example 3: Return typeahead information for sourcetypes in the _internal index
When you run the following
typeahead search, Splunk software returns typeahead information for sourcetypes in the _internal index.
| typeahead prefix=sourcetype count=5 index=_internal
The results look something like this.
This documentation applies to the following versions of Splunk® Enterprise: 9.0.0, 9.0.1, 9.0.2, 9.0.3, 9.0.4, 9.0.5, 9.0.6, 9.1.0, 9.1.1