Thangaraj - Is there a way to update search que...
# dev-help
t
Is there a way to update search query programmatically in embedded integration? We are using search ended component
a
message has been deleted
s
Yes — for SearchEmbed, you can set/update the query programmatically using the embed config and event trigger flow. If you meant “search ended” as SearchEmbed (not SearchBar), the supported approach is: 1. Render SearchEmbed 2. Use SDK event trigger APIs (
trigger(...)
) to interact after load For the exact host event to update query text in your SDK/version, check the HostEvent list for your version and use
embed.trigger(...)
(the docs explicitly support trigger-based app interaction).
Copy code
javascript
import {
  init,
  AuthType,
  SearchEmbed,
  EmbedEvent,
  // HostEvent, // use the exact HostEvent from your SDK docs for updating search/query text
} from '@thoughtspot/visual-embed-sdk';

init({
  thoughtSpotHost: 'https://your-ts-host',
  authType: AuthType.None,
});

const searchEmbed = new SearchEmbed('#tsEmbed', {
  dataSource: 'YOUR_WORKSHEET_ID',
});

searchEmbed
  .on(EmbedEvent.Load, async () => {
    // Example pattern:
    // await searchEmbed.trigger(HostEvent.<QUERY_UPDATE_EVENT>, { ...payload });
  })
  .render();
If you share your SDK version, I can give you the exact HostEvent name + payload for updating the query string in SearchEmbed.
t
What's the host event I have to trigger? I am trying with host event.search with the updated searchTokenString but it's not working
Just to clarify, this issue is not happening for all SearchEmbed cases. In my case,
hostEvent.search
is not working specifically when the Saved Answer’s default visualization is set to a Pivot Table. The same flow works correctly when the visualization is changed to a regular table.
r
Hi @Thangaraj Are you seeing any error when using search host event ? Also, we have AddColumns/RemoveColumns host event as well, did you explore those for your use case ?