In general it might be a good idea to block crawling of search result pages, but there are cases where it can makes sense to allow crawling.
For example, if your search is the only or the primary way to navigate the site, and especially if you offer filters (or search operators) with pre-defined search terms. So instead of having a separate /category/ namespace (e.g., /category/movies), some sites use the search function for this: /search/category:movies.
And besides that: Even if you disallow crawling of search result pages, it can still make sense to provide the canonical link type for these pages (all kinds of tools might use it, e.g., for bookmarking).
So here’s an answer to the original question:
It would be wrong to use example.com/search/index.php as canonical URL for example.com/search/index.php?keywords=fruits_bananas_apples.
RFC 6596 makes clear that the canonical URL
[…] MUST identify content that is either duplicative or a superset of the content […]
As /search/index.php does (most likely) not contain or include the content from /search/index.php?keywords=fruits_bananas_apples, it’s not allowed to be specified as canonical URL.
A case where it would be appropriate for a search result to use the canonical link relation (just as an example to give you an idea, probably not worth to implement this one): Assuming that the order of the search terms does not matter, you could decide to use the URL with the search terms in alphabetical order as canonical URL, e.g.,
/search/index.php?keywords=apples_bananas_fruits
for URLs like
/search/index.php?keywords=apples_fruits_bananas
/search/index.php?keywords=fruits_bananas_apples
…
Search pages should be disallowed from crawling with the robots.txt. – dan May 25 '16 at 05:55Search pages should be disallowed from crawling with the robots.txtthis is exactly what i wanted. thanks for the information
– Naofumi Fujii May 25 '16 at 05:58