Solr, Finder, campaigns, Search Development and Troubleshooting - DoSomething/legacy-website GitHub Wiki

##Indexing

Any content that needs to be served by Solr needs to be indexed.

  • Apachesolr module automatically indexes all new fields

  • Field types (sm_, ss_, bs_, etc.) are based on the field type definition in CCK

  • Indexing runs on cron, once an hour, or it can be kicked off manually at admin/config/search/apachesolr/settings/solr/index

  • Immediately add a campaign to the search index so that it shows up in search, finder, and at /campaigns:

    1. Navigate to https://www.dosomething.org/admin/config/search/apachesolr
    2. Select "Index queued content (50)".

####Troubleshooting:

  1. Make sure the solr path at admin/config/search/apachesolr/settings/solr/edit is correct and connecting to Solr
  2. Make sure there are no other cron errors
  3. If the data in the production solr environment has been overwritten/is incorrect: a. Visit admin/config/search/apachesolr/settings/solr/index b. Delete the solr index. Beware that this will break all search functionality temporarily c. Run cron repeatedly or use the "Index queued content" button repeated to index all content. (There's a Varnish issue with running batch commands in production)

##/campaigns

####Powered by views and apachesolr views

  • Page view with two filters, four fields

  • No items without the appropriate image will show up

  • elevate.xml is a hardcoded file that bumps a specified list to the top - lives in /opt/solr/collection1/conf on the solr box

####Troubleshooting:

  • If /campaigns isn't showing anything and there are many htmlspecialchars errors

    1. Make sure the solr path at admin/config/search/apachesolr/settings/solr/edit is correct and connecting to the correct Solr instance.
    2. Clear views cache
  • If an item isn't showing up, make sure it has the correct sized image associated with it, and that that information is properly indexed in solr.

##Finder

####Complete client side code that structures queries that return results to the user

  • Solr settings like which fields are returned and what filters are applied are in SolrAdapter.js

  • Queries are built in Finder.js

  • The code is pointing to the production solr box so any results you see in any environment are from prod

  • To hide things from the Finder, a value has to be added to the fq param in the default query in SolrAdapter.js

  • To boost things in the Finder, similarly a value has to be added to the bq param

####Troubleshooting:

  • Check the network tab in the browser to make sure that requests to search.ds.org are succeeding

##Search

####Drupal search is using apachesolr search as the default

  • Content type, core field, and result biases/boosts are set here - admin/config/search/apachesolr/settings/solr/bias

  • To add additional boosts, add to the bq param in dosomething_search_apachesolr_query_alter();

  • The fl param is set in dosomething_search_apachesolr_query_alter() which means that only certain fields will be returned. Returning or not returning these fields does not affect the results. If add'l fields are needed for display purposes, add to the fl param, keeping in mind that adding more fields slows down the response time

####Troubleshooting:

  • Make sure the solr path at admin/config/search/apachesolr/settings/solr/edit is correct and connecting to Solr
  • Make sure that everything is indexed admin/config/search/apachesolr/settings/solr/index
  • Make sure the biases and indexed content types haven't been deselected by a features revert

##Solr/Apachesolr Search Development Tips

  • Every environment defaults to solr:8080/collection1 or solr:8080/COUNTRY as the solr URL. This is specified at admin/config/search/apachesolr/settings/solr/edit, and set in settings.php, settings.local.php, and dosomething_search.apachesolr_environments.inc.

  • To run queries directly against the solr server, check the tech wiki for the underlying IP addresses. Building queries this way will help isolate any potential integration issues.

  • When adding Views, make sure query debugging is turned on. Apachesolr Views has handy output of exactly what's being sent to Solr

  • To add items to elevate.xml, first get their ids from the appropriate environment with the solr admin interface. Check the tech wiki for the IP address and URL for the admin interface.

  • If elevate.xml isn't being respected, make sure the 'elevator' component has been added to 'last-components' in the pinkPony request handler located in solrconfig.xml