Trending Searches
Stay organized with collections
Save and categorize content based on your preferences.
Get Trendings
To get trending searches, call the getTrendingSearches
method on the
ContextualSearchRuntime
. This method takes a single
GetTrendingSearchesOptions
where you can specify the maximum number of trendings returned.
The returned SearchSuggestions
object does not contain any accessible
properties. It contains all of the necessary information to render trending
searches, but otherwise is opaque.
Swift uses the Swift Concurrency style, Objective-C uses a callback function.
Objective-C
getTrendingSearchesWithOptions
[searchRuntime
getTrendingSearchesWithOptions:
[[GetTrendingSearchesOptions alloc] init]
completionHandler:^(SearchSuggestions *_Nullable suggestions,
NSError *_Nullable error) {
// error will be not null if there is an error.
// On success, suggestions will be non null.
}];
Display
To display trending searches chips, use the same way
as the search suggestions.
Next: Display search resultsarrow_forward
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-05 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-05 UTC."],[[["Utilize the `getTrendingSearches` method within `ContextualSearchRuntime` to retrieve current trending searches, specifying the desired maximum number through `GetTrendingSearchesOptions`."],["The returned `SearchSuggestions` object, while crucial for rendering trends, doesn't expose direct properties for data access."],["Swift leverages Swift Concurrency with `Task` and `await`, while Objective-C relies on a callback function for handling results and errors."],["Trending searches can be displayed using the same approach as standard search suggestions, ensuring visual consistency."]]],["To retrieve trending searches, use the `getTrendingSearches` method of `ContextualSearchRuntime`, providing `GetTrendingSearchesOptions` to set the maximum results. Swift employs async/await, while Objective-C utilizes a completion handler. The `SearchSuggestions` object returned is opaque, solely intended for rendering. Display trending search chips similarly to search suggestions using the method described in another page. Both languages provide the necessary tools to retrieve and handle trending search data.\n"]]