Skip to content

Instantly share code, notes, and snippets.

@rosiel
Last active March 15, 2023 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosiel/4e04bc45cdc3de83cff1845d68daa2d5 to your computer and use it in GitHub Desktop.
Save rosiel/4e04bc45cdc3de83cff1845d68daa2d5 to your computer and use it in GitHub Desktop.
advanced search instructions

Use Advanced Search and Collection search

written for release 0.4.0 of the Islandora Starter Site.

Which version to use

  • Use UTSC's version, at https://github.com/digitalutsc/advanced_search. It has the advanced features that are described here (particularly Extended Dismax, up-to-date AJAX handling, and Keyword (all-fields) search). Get it with Composer (you'll have to define your own repository) as composer require islandora/advanced_search:dev-contrib and enable it with Drush.
  • If you're using Islandora's Advanced Search, uninstall it.

Set up Advanced Search

Configure global options

  1. Go to the Advanced Search configuration page and set up whether you want to use Extended DisMax searching (probably yes) and "Enable searching all fields" (also yes).
  2. While you're there, configure the pager block to offer List and/or Grid as options, and which should be the default.

Set up a view to power Advanced Search

Follow the directives and images in the module's README for setting up a Search API view. The requirements are extensive and somewhat unconventional, including:

  • AJAX must be on.
  • options for sorting must be made available to the user
  • options for number of items per page must be made available to the user
  • There must be a Results Summary displayed, and its text must contain a certain HTML snippet.
  • The exposed form must not require input.
  • The view must have at least one facet configured.
  • if you want this to be a Search-within-colletion view (see next section; omit this for a global search view), some contextual filters must be placed.
    • more, perhaps, within the README.

Place Blocks

Once the view is set up, place the following blocks:

  • Search
    • this is a global search view; direct it at your search page.
  • [VIEW_NAME] Advanced Search for [DISPLAY_NAME] [for the view and display you're using]
  • [VIEW_NAME] Search Results Pager for [DISPLAY_NAME] [also for the view and display you're using]
  • [One or more facet blocks for this view and display - without this, the advanced search blocks won't work]
  1. Each block should be configured to only display on the page of your search view. You can do this either by configuring the Path, or by using View Inclusion, which automatically updates if you change the view's path. Or you could potentially place your block using a Context, or any other method you have available. i. Note: These blocks should not be placed via Contexts. It seems there is something funky in one of the Advanced Search blocks that causes it to whitescreen when the blocks are placed this way. In the Starter Site all blocks are placed at Structure > Blocks.
  2. When you are installing the Advanced Search block, you have the option to select fields to be searchable.
    • If you choose fields that are stored in Solr as 'fulltext' then you will have nice, predictable behaviours. However, if you use 'string' fields or other types, then searches will only cause a match where all the search terms occur as an exact phrase. I prefer using fulltext fields because it functions more like modern search interfaces.
    • Be careful that you know what fields contain - for example, if you try to create an aggregated field for the various subject fields we have, that field will only contain the term IDs, and it's unlikely that someone will know to search for '71' (for example). This is why we don't have a subject field in the advanced search setup in the starter site.
  3. The Search Results Pager block does not have any options, but what is available in terms of results-per-page and sorting are drawn from the exposed options that are set up in the view. Whether Grid and/or List view are available, and which one is default, are configured globally in the Advanced Search module's settings.
  4. The blocks will not work until at least one facet is placed for this view display. Some configuration settings I've found good are: 1. "Hide inactive siblings": removes values that aren't present after you've narrowed. 2. Don't use "Show reset link" 3. Don't "Hide non-narrowing results" 4. Use "Hide facet when facet source is not rendered" 5. Minimum count 1. 6. For the most part, use the default sort order. Dates (years) were sorted only by value.

Set up Search Within a Collection

  1. Create a "Block" display within the same view you used above, and for that block ONLY, add contextual filters based on field_member_of. This will be your search-within-a-collection view display (probably block_1).
    1. There is an optional "Include subcollections" button that is part of the Advanced Search block. To get it working, you need to have two different indexed fields - one (field_member_of for example) that does not use the hierarchy processor so only takes the immediate parent, and a second (e.g. field_descendant_of) which uses hierarchy so includes all ancestors.
  2. Ensure your view display is configured properly (see section above).
  3. Configure the Advanced Search block for this block display to appear.
  4. If you configured two contextual filters, then this block's configuration page will have an option to select which one is used for sub-collection search.
  5. Create facets to your liking for this Collection Search (block). It's a pain but there needs to be a separate set of facets for each view display.
    1. As a tip, name the facets something that can help identify which display it belongs to. In the starter site, "search within collection" facets include the term _swc.
    2. Another tip for placing blocks: Set up (or use the existing) Context that detects Collections (e.g. using the Field Model's value of Collection). However, do NOT place any blocks here in the Context - some of the Advanced Search blocks don't work if they're placed this way. Instead, when placing your "search within this collection" blocks (using the Structure > Blocks interface), utilize the "Context (All)" filter (or "Context (Any)") to only show this on things which are Collections.
  6. Place the "Pager block" for the Collection view, as above.

Note: Search highlighting seems to not work within these advanced search views.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment