Following up on my message about the search tuning plugin I was working on
- I'm done working on it and it's safe to use if you want to try it out:
https://github.com/NCSU-Libraries/archivesspace_search_title_boost

All it does is boost search results where the words in your query all match
words in the title field (which is a catch-all field for names, labels,
terms, etc, not just for actual titles). It gives an extra boost to records
where there is an exact match on the beginning of the value (e.g. a search
for 'cats' will boost 'cats on parade' over 'parade of cats').

One big difference between this and Hudson Molonglo's and_search plugin
<https://github.com/hudmol/and_search> is that this one will not affect the
total number of results returned but instead will just boost the relevancy
score for records where all of the words in the query match the title
field. Opinions will differ on which is better. Both plugins affect the
core search that is used in the staff and public interfaces.

If you're comfortable with Solr or brave enough to try to be, you can take
this code and customize it for your own needs. Here's how it works - it's
pretty simple (again, I borrowed this approach from HM so thanks to them):

1. It's really just one file -* backend/plugin_init.rb* - and in looks like
this:

ArchivesSpaceService.loaded_hook do
  Solr.add_search_hook do |query|
*    query.add_solr_param('bq', "title:\"#{@query_string}\"*")*
*    query.add_solr_param('pf', 'title^10')*
*    query.add_solr_param('ps', 0)*
  end
end

2. The lines that start with *query.add_solr_param* each add a parameter to
the Solr query and take 2 arguments (the bits inside the parentheses). The
first is the parameter name and the second is the value.

3. You can pass in any parameters available in the Solr Extended DisMax
Query Parser
<https://lucene.apache.org/solr/guide/6_6/the-extended-dismax-query-parser.html>,
which includes parameters from the Dismax parser
<https://lucene.apache.org/solr/guide/6_6/the-dismax-query-parser.html#the-dismax-query-parser>
and the Lucene parser
<https://lucene.apache.org/solr/guide/6_6/the-standard-query-parser.html#the-standard-query-parser>.
Use appropriate caution - it's safer to use parameters that adjust the
relevancy score of the results rather than the changing the overall scope
of the query.

4. A little more advanced:

a. any instance variables defined here can be used:
https://github.com/archivesspace/archivesspace/blob/99f611ce18c4a4c27cabcd294caf32b48cb7ed06/backend/app/model/solr.rb#L63

b. check out the Solr schema if you need more info about what fields are
available:
https://github.com/archivesspace/archivesspace/blob/master/solr/schema.xml

Let me know if you have questions and/or suggestions (or if you know more
than I do about this and I got anything wrong!)

-Trevor



On Wed, Feb 7, 2018 at 5:08 PM, Trevor Thornton <trtho...@ncsu.edu> wrote:

> I've been working on a plugin (based on the approach HM used in their
> and_search plugin) that deals with the problem a little differently -
> instead of changing the default operator to AND it boosts results for
> phrase queries (multiple words separated with spaces) where there is an
> exact match in the Solr 'title' field:
>
> https://github.com/NCSU-Libraries/archivesspace_search_title_boost
>
> On Wed, Feb 7, 2018 at 4:53 PM, Celia Caust-Ellenbogen <
> ccaus...@swarthmore.edu> wrote:
>
>> Is there a ticket for this problem, of the default OR instead of AND,
>> yet? I couldn't find one, so I created it here, if anyone else wants to
>> vote: https://archivesspace.atlassian.net/browse/ANW-427
>>
>> On Thu, Jan 4, 2018 at 9:45 AM, Trevor Thornton <trtho...@ncsu.edu>
>> wrote:
>>
>>> We've had this problem in the staff interface. The typeahead
>>> functionality is basically useless in a lot of cases, but searching with
>>> the 'browse' modal generally works better. If you're searching for a phrase
>>> it always works better to wrap it in double quotes to avoid the default OR
>>> issue.
>>>
>>> On Tue, Jan 2, 2018 at 4:52 PM, Kevin Clair <kevin.cl...@du.edu> wrote:
>>>
>>>> Hello,
>>>>
>>>>
>>>>
>>>> We’ve noticed some peculiar behavior when adding Related Agent links to
>>>> Corporate Entity records in ArchivesSpace. When typing the name of the
>>>> Agent we wish to link in the Related Agents form, the typeahead drop-down
>>>> list populates with unrelated terms. For example, if we were to try and
>>>> enter a University of Denver constituent unit as the later form of a name
>>>> for a different DU corporate entity, typing “university of denver” into the
>>>> text field brings up a drop-down list of mostly Family records. This only
>>>> happens when the search string contains spaces; searches on a single word
>>>> bring up more or less the results we would expect.
>>>>
>>>>
>>>>
>>>> Two screenshots are attached: one with the results when “university” is
>>>> the search, and one with the results when “university of denver” is the
>>>> search (the drop-down results are the same whether or not the period is
>>>> included).
>>>>
>>>>
>>>>
>>>> Has anyone else noticed anything like this?
>>>>
>>>>
>>>>
>>>> thanks!  -k
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Archivesspace_Users_Group mailing list
>>>> Archivesspace_Users_Group@lyralists.lyrasis.org
>>>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>>>>
>>>>
>>>
>>>
>>> --
>>> Trevor Thornton
>>> Applications Developer, Digital Library Initiatives
>>> North Carolina State University Libraries
>>>
>>> _______________________________________________
>>> Archivesspace_Users_Group mailing list
>>> Archivesspace_Users_Group@lyralists.lyrasis.org
>>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>>>
>>>
>>
>>
>> --
>> Celia Caust-Ellenbogen
>> Friends Historical Library of Swarthmore College
>> <http://swarthmore.edu/friends-historical-library>
>> 610-328-8496 <(610)%20328-8496>
>> ccaus...@swarthmore.edu
>> she/her/hers
>>
>>
>>
>> _______________________________________________
>> Archivesspace_Users_Group mailing list
>> Archivesspace_Users_Group@lyralists.lyrasis.org
>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>>
>>
>
>
> --
> Trevor Thornton
> Applications Developer, Digital Library Initiatives
> North Carolina State University Libraries
>



-- 
Trevor Thornton
Applications Developer, Digital Library Initiatives
North Carolina State University Libraries
_______________________________________________
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

Reply via email to