Programmatically geocode locations

I would like my cesium component to do a location search programmatically. Is there any way of doing that?

The one way I tried doing is injecting the search string to the Geocoder object directly, and then calling the search function in the view model, but the text doesn't appear in my geocoded nor does the searching happen:

    var geocoder = viewer.geocoder;
    geocoder.searchText = "Seattle, CA";
    geocoder.viewModel.search();

I had only found one mentioning regarding custom queries but that was more towards having a callback to override the Geocode widget's search function:
https://groups.google.com/forum/#!topic/cesium-dev/Pr2vv87299I

Hi,

See the geocode() function here: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Widgets/Geocoder/GeocoderViewModel.js#L218

Decoupling the geocoder from the UI is also on the roadmap, see #1262.

Patrick

Thanks for the response Patrick.

I am able to set the searchText but when invoking the geocode function but I am having some trouble determine on which object the geocode function is defined, I tried both of the following:

viewer.geocoder.viewModel.geocode is not a function
viewer.geocoder.geocode is not a function

Also, the Geocoder documentation has no mention of a geocode function for GeocoderViewModel, just a search command.
https://cesiumjs.org/Cesium/Build/Documentation/GeocoderViewModel.html

Am I reading the code wrong? Any more pointers would be most appreciated!