Hi @sankaran ,
Recommendation is one of my favourite features of Adobe Target - just as much as i love it, I hate having to show that it actually works when only a few products has been uploaded. Ideally you implement it on all pages, let it collect behaviour for a week or two and then it will be much easier.
It is worth keeping in mind that Recs is driven by the behaviour of the users, so in order for it to show/recommend something it isn't enough to just upload a few products. There needs to be some behaviour in order for a Criteria like 'people who viewed this also viewed that' to work.
In order to track the behaviour you need to implement target requests on the product detail pages that sends in the entity.id parameter - this is what is used to track the behaviour. Creating the products via API is primarily used for enriching the product with meta data if you're not doing this via the target requests on the product detail page.
If you only have the products created via api, these are your options:
1) hardcode a custom criteria to show products (my preferred option). This still requires that entity.id is set on the page where you would like to see it working.
2) if you have Adobe Analytics implemented and the SKU collected in AA is the same as you used when uploading products to Recs you can update the criteria to use Adobe Analytics behaviour data. Again, you still need to ensure you have entity.id set on the page where you would like to see it working.
In your specific case where you would like to return something based on a search, you need to set entity.id on the search result. You need to ensure that entity.id has an id of a product that exist in your catalogue, which sometimes can be difficult on a search result page. Typically this is achieved by capturing the SKU of the first product the search is returning.
Let me know how it goes!