Added term facets to search query. #6543

Added a test for facets.
add an intermediate method to get attributes_names for faceting and downstream modules can override that method to add attributes