Restore Local Params in Solr 7.5

by Peter Tyrrell Thursday, December 06, 2018 12:13 PM

Local params are a way of modifying Solr's query parser within a query, setting all related parameters with a shorthand syntax. Super convenient for modifying query behaviour on the fly; local params are disabled by default in Solr 7.5, when employing the edismax query parser.

TL;DR

Modify the request handler in solrconfig.xml to add the so-called 'magic field' uf=_query_ back to the uf (User Fields) parameter to restore the kind of local params behaviour that was default prior to Solr 7.5.

<str name="uf">* _query_</str>

The above allows users to do fielded searches on any field, plus allows them to use local params in their queries.

Why Local Params? An Example

Say we are developers who want to use the MoreLikeThis feature of Solr. There are multiple ways of setting this up, as described in the Solr Reference Guide. But, say we are also developers who are using SolrNet to create requests to and handle responses from Solr. (As indeed is the case for use here at Andornot, in our Solr-backed Discovery Interface.)

One of SolrNet's strengths is that it maps Solr responses to strongly-typed classes. On the other hand, its weakness is that you can really only map query result documents to one strongly-typed class. (Not strictly true, but true from a practical, please-don't-make-me-do-contortions point of view.)

No response from Solr can deviate too far from that mapping. Other bits can be tacked on to the response and be handled by SolrNet (highlighting, spellcheck, facets, etc.), but these must be components that are somehow related to the context of the documents in the main response. In the case of MoreLikeThis, you have to set up the component so that each query result document generates a list of 'like' documents. Having to generate such a list for each document returned slows down the query response time and bloats the size of the response. Quite unnecessary, in my opionion. I much prefer to generate the list of 'like' documents on the fly when the user has asked for them. An easy way of doing that without messing with the SolrNet mapping setup is to use local parameters.

Say our user finds an intriguing book in their search results called "More Armadillos Stacked on a Bicycle". Perhaps, our user muses, this book is a sequel to a previous publication regarding such matters. They feel a thrill of anticipation as they click on a 'More Like This' link. (I know I would.)

{ 
   'id': 123, 
   'title': 'More Armadillos Stacked on a Bicycle', 
   'topic': [ 
      'armadillos', 
      'fruitless pursuits', 
      'bicycles' 
   ] 
}

When using local params, the 'More Like This' query can use the same Solr request handler and all the parameters embedded within it, but swap out the query parser for the MLTQParser. The bits that are needed to complete the MoreLikeThis request are passed in via local param syntax, still within the main query parameter! (Perhaps I did not need that exclamation mark, but the armadillos-upon-a-bicycle adrenaline has not yet worn off.)

/select?q={!mlt qf=title,topic mintf=1 mindf=1}123

The local params syntax above says "find other documents like id=123 where extracted keywords from its various fields find matches in title and topic." The convenient part for the developer using SolrNet is that the response maps neatly to the kind of response we expect from a regular query: a set of result documents mapped to a strongly-typed class, which makes the response easy to handle and display using existing mechanisms.

Why Not Local Params?

I suppose we can imagine a clever and malicious user who is able to use the power of local params to hack Solr queries in order to get at information that perhaps they otherwise shouldn't. If, as a developer, you need to ensure that users are limited in their scope, then disabling local params and even further locking down the uf (User Fields) parameter to deny certain fielded searches is right and good.

Andornot's November 2018 Newsletter Available: News, Tips and Tricks for Libraries, Archives and Museums

by Jonathan Jacobsen Monday, November 19, 2018 7:35 AM

Tags: newsletters

How To Create a DB/TextWorks Menu Screen

by Jonathan Jacobsen Thursday, November 15, 2018 10:36 AM

For some reason, DB/TextWorks menu screens are a little used feature. We often meet clients with many databases, but without a convenient way of seeing and accessing them all at a glance. Adding a menu screen to DB/TextWorks is quick and easy to do, but makes using your databases so much easier.

The screenshot above shows the menu screen from our Andornot Library Kit, with links to each of the many databases it includes. The one below shows one from one of our clients' systems.

What is a Menu Screen?

Like a Query Screen or Report Form in a DB/TextWorks database, a Menu Screen is a screen layout you create using the WYSIWYG designer in DB/TextWorks. You would usually add to it links to each of your databases, for searching or data entry. You might also add your organization's name or logo, contact or support info for anyone who might be using the system, a brief description of each database, etc.

Having links to all your databases on a single screen saves time and helps new users find their way around your collection of databases without having to hunt for them in folders on disk. It also allows you to specify, in each link to a database, which query screen and reports to load for that database. 

One way to create menu screens is to have different menu screens for different kinds of users. For example, in an archives or museum that relies on volunteers to help with data entry, you could have a menu screen for volunteers that only lists the Accessions database, and pre-loads a simpler query screen and data entry form designed specifically for volunteers. A more extensive menu could provide the archivist or curator with links to all databases, pre-loading the more sophisticated query and edit screens for their use.

Unlike a Query Screen or Report Form, the menu screen isn't stored in any one database, but rather as a separate file on disk (with a .tbm or .cbm extension). You would usually store it in the same folder as all your database files.

How do I create a Menu Screen?

  1. Open DB/TextWorks but don't open a database.
  2. Select Menu Screens > Design from the main menu.
  3. Choose "Create a New Menu Screen File."
  4. Browse to the folder where your databases are stored to save the menu screen in the same location, and give it a name.
  5. In the WYSIWYG Menu Screen Designer, you may now add links to textbases, your organization's name or logo, and other information. Use the examples above for ideas, or come up with your own design.
  6. To add links to textbases, choose Edit > Add > Textbase box.
  7. In the Textbase Properties Dialogue, select the textbase to link to, then on the Initial Elements tab, pre-select the query screen and forms to use by default. Note that these override the default screens and forms set in the textbase, and that in either case, users may still change to other screens and forms once they are in the database.
  8. On the Initial Action tab, be sure to select which window to open. For example, if your link is one such as "Search the Database", select a Query Window. If your link is "Add a New Record", select Edit New Record as the window to open.
  9. Save your new menu screen when your design is complete.
  10. If you ever create more than one menu screen, you can even add links from one to another on each of them.

How do I use a Menu Screen?

  1. On each PC that has DB/TextWorks, open DB/TextWorks but don't open a database.
  2. Select Menu Screens > Select from the main menu.
  3. Choose "Use the Menu Screen in a File", then browse to and select the Menu Screen file (ending with .tbm or .cbm) that you created earlier, usually stored in the same folder as your databases.
  4. Close and re-start DB/TextWorks and your menu screen will now automatically load, ready for use.

See this blog post from earlier this week about two other helpful but little used features of DB/TextWorks: Sets and Record Skeletons.

3 under-used DB/TextWorks functions that you might find useful

by Kathy Bryce Tuesday, November 13, 2018 9:28 AM

A recent project has reminded me that many clients are not aware of the power of these three functions that have been available in DB/TextWorks for years, and which can potentially streamline and speed up your workflow.

The first is Menu Screens.  Many clients have a menu screen that loads up when they open DB/TextWorks but usually the ones we see are either the default from the old Inmagic Library Module, or rudimentary boxes linking to their databases. However they can be so much more useful! Here is an example from a recent project.

CLGA menu

A menu screen is super easy to set up and we’ll be posting a detailed guide here in our blog soon.

However first we need to discuss the other two functions, as they can be used separately or in conjunction with your menu screen.

The second function is Sets. Whenever you do a search you can choose to Save the Set from the top toolbar. Sets are a great way of providing quick access to a search with several parameters to save you from entering them each time using the query screen. So for example, find all records with a Review date in the next 30 days; or find digital image records that have been entered but not checked yet; or find all books that are not on permanent loan and that have been out for more than 60 days. You can use the @date variable in the search strategy without needing to actually input an actual date each time. Never used the @date function? It can be very handy especially when combined as in @date-7:@date which retrieves all dates within the past week.   A Sets box can be added to your query screen to give you quick access to running these searches or they can be embedded in your menu screen.

The third function is Record Skeletons. You may have a student or volunteer adding records for reports in particular series; or images in a photographic collection; or documents in a fonds. You can create a record skeleton to prepopulate the edit screen with publication or descriptive data that is common to all these new records. You can find Skeletons under the Records menu. Note that once you select a skeleton to use, it will be the default until you re-set to none, or choose a different one.

In the menu screen example above, every database has a link to the search screen plus a link straight in to a new record edit screen. If your database has several edit screens these can be specified on the menu screen too, as well as specifying a skeleton appropriate for these new records. It may not seem like much, but this can save a couple of extra clicks and let you get straight to work. This screen also has Sets specified to prepopulate the query screen with the value for a particular collection. So easy to set up and a great way to ensure people can search quickly and effectively.

Check out more tips and tricks for getting the most out of DB/TextWorks in our blog archive:

We are always available to help you with updates to your databases. No project is too small!

Andornot's Professional Development Grant Available for 2019

by Jonathan Jacobsen Tuesday, November 06, 2018 8:20 AM

Andornot strongly believes in the value of attending conferences to foster professional development.

Two years ago, we introduced the Andornot Professional Development Grant, a new, annual grant to help you attend a conference or event as part of your ongoing professional development activities. Of the many excellent applications we received each year, Mark Goodwin of the BC Cancer Agency was selected in 2016, and Gayle Graham of the Nova Scotia Health Authority received the grant in 2017. Both used the funds to help them attend the Canadian Health Libraries Association Conference.

We are very pleased to be able to offer the grant again this year, to help you attend an event in 2019.

One grant of up to $1,000 is available, with an application deadline of January 31st, 2019. The funds can be used for registration or travel related expenses. We hope that this grant will provide an opportunity for someone without access to funds from their organization to network and enrich their knowledge.

To apply, just complete this application form. The recipient will be selected in early February, allowing time to register for a conference at any point in the year.

Tags: funding

Month List