Created
November 4, 2015 20:18
-
-
Save carolyncole/235e684f56c89849598a to your computer and use it in GitHub Desktop.
Blacklight Search Build Ad Hock Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySearchBuilder < Blacklight::Solr::SearchBuilder | |
def my_search_stuff(solr_parameters) | |
# optionally change facets | |
solr_parameters[:"facet.field"].concat([Solrizer.solr_name("my field", :symbol)]) | |
# Optionally change facet limit | |
solr_parameters[:"facet.limit"] = my_count | |
# optionally filter the records | |
solr_parameters[:fq] = "has_model_ssim:MyModel" | |
# optionally get only the facets | |
solr_parameters[:rows] = 0 | |
#anything you can change on the solr parameters... | |
end | |
end | |
#calling code in some class or contorller | |
include Blacklight::Base | |
copy_blacklight_config_from(CatalogController) | |
def my method | |
sb = MySearchBuilder.new([:my_search_stuff], self) | |
facet_results = repository.search(sb.query) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment