[Archivesspace_Users_Group] SOLR/API differences

Andrew Morrison andrew.morrison at bodleian.ox.ac.uk
Mon Aug 23 08:27:40 EDT 2021


The search endpoints of the ArchivesSpace API allow passing of queries 
to Solr, but only selected parameters such as q and sort are passed 
directly through. Sorry if I gave you the wrong impression in previous 
emails.


You cannot specify qf in an API search. Instead, its value is hardcoded 
here:


https://github.com/archivesspace/archivesspace/blob/master/backend/app/model/solr.rb#L278


A few lines further down you can see where it calls hooks, which can be 
set up in plug-ins. So you can override the qf that way, but doing so 
will apply to all searches everywhere (in the public user interface and 
staff interface) not just specific API calls. Alternatively, it might be 
possible to write a plugin to create a new endpoint to allow dynamic 
setting qf, if it is crucial for your use-case.


Some Solr parameters have equivalents in the ArchivesSpace API, which 
are listed here:


https://archivesspace.github.io/archivesspace/api/#search-this-repository


For example, instead of fl there is the fields[] parameter. And, 
although it is missing from the documentation, you can do fq, except it 
is renamed filter_query[]. The defType is already set to edismax. 
Instead of rows you have to use page_size, but if you want 1000 hits per 
page then you need to change AppConfig[:max_page_size] in config.rb.


The summary field can be set to indexed="true" in schema.xml. I've done 
so myself, but on a system that uses an external Solr server, with its 
own schema.xml. In a system running from a built release, and using 
internal Solr, schema.xml is inside a .war file.


Andrew.




On 20/08/2021 14:42, RENTON Scott wrote:
> Hi folks
>
> Just trying to translate a query worked out in SOLR into an API get 
> request.
>
> Here, I'm trying to use edismax and qf to limit the fields I'm looking 
> in for a term, so we don't get unwanted content coming through:
>
> [base_url]/collection1/select?q=joke&fq=types%3Aarchival_object&rows=1000&fl=title+notes+summary&wt=json&indent=true&defType=edismax&qf=notes%5E300+title%5E100&stopwords=true&lowercaseOperators=true 
> <http://lac-archivesspace-live2.is.ed.ac.uk:8090/collection1/select?q=joke&fq=types%3Aarchival_object&rows=1000&fl=title+notes+summary&wt=json&indent=true&defType=edismax&qf=notes%5E300+title%5E100&stopwords=true&lowercaseOperators=true>
>
> That does seem to work.
>
> When I drop it into the API, though, I notice that fq is ignored (I 
> just move the types into the q, that's ok), fl is ignored (this was 
> just to see things easily, not a big deal), and even with 
> defType=edismax, the all-important qf is ignored. Is that what we'd 
> expect?
>
> My GET looks like this (I took the weightings off the qfs):
> [base_url]/repositories/2/search?q=joke AND 
> types:archival_object&rows=1000&fl=title+notes+summary&wt=json&indent=true&defType=edismax&qf=notes+title&stopwords=true&lowercaseOperators=true&page=1
>
> I was under the impression the API and SOLR syntax were 
> interchangeable, but perhaps not?
>
>
> I've also noticed that I cannot use summary for qf in SOLR. I think 
> this is because it is indexed="false" in schema.xml. Is it likely to 
> be safe to change that and reindex?
>
>
> Thanks
>
> Scott
>
>
> ==========
>
> Scott Renton
>
> Digital Library Development & Systems
>
> Floor F East
>
> Argyle House
>
> 515219
>
> The University of Edinburgh is a charitable body, registered in 
> Scotland, with registration number SC005336. Is e buidheann 
> carthannais a th’ ann an Oilthigh Dhùn Èideann, clàraichte an Alba, 
> àireamh clàraidh SC005336.
>
> _______________________________________________
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group at lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20210823/0d4b92a8/attachment.html>


More information about the Archivesspace_Users_Group mailing list