Re: [Archivesspace_Users_Group] Error setting parent of Archival Object via API

2021-08-23 Thread James Bullen

Hi Tommy,

I’m ready to be wrong on this, but just had a quick look and it seems like the 
position param is required even though the endpoint declares it as optional.


Cheers,
James


> On Aug 24, 2021, at 9:30 AM, Keswick, Thomas (Tommy)  
> wrote:
> 
> Greetings.
> 
> I’m trying to use the Set the parent/position of an Archival Object in a tree 
> 
>  API endpoint but I am getting an error when I supply both the archival 
> object ID and the parent ID in what should be the correct way. The Archival 
> Object is an item-level record and the parent is a series-level record, both 
> under the same Resource.
> 
> The error is:
> {
> "error": "comparison of Integer with nil failed"
> }
> 
> Here is some sample Python code that fails:
> ```
> import json
> 
> from asnake.client import ASnakeClient
> 
> asnake_client = ASnakeClient()
> asnake_client.authorize()
> 
> parent_post_response = asnake_client.post(
> "/repositories/2/archival_objects/96413/parent?parent=96414"
> )
> print(json.dumps(parent_post_response.json(), sort_keys=True, indent=4))
> ```
> 
> The locally installed ArchivesSpace version that I am testing on is 2.8.1 
> currently.
> 
> Thanks for any help.
> 
> Cheers,
> Tommy
> 
> ___
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group@lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

___
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group


[Archivesspace_Users_Group] Error setting parent of Archival Object via API

2021-08-23 Thread Keswick, Thomas (Tommy)
Greetings.

I’m trying to use the Set the parent/position of an Archival Object in a 
tree
 API endpoint but I am getting an error when I supply both the archival object 
ID and the parent ID in what should be the correct way. The Archival Object is 
an item-level record and the parent is a series-level record, both under the 
same Resource.

The error is:
{
"error": "comparison of Integer with nil failed"
}

Here is some sample Python code that fails:
```
import json

from asnake.client import ASnakeClient

asnake_client = ASnakeClient()
asnake_client.authorize()

parent_post_response = asnake_client.post(
"/repositories/2/archival_objects/96413/parent?parent=96414"
)
print(json.dumps(parent_post_response.json(), sort_keys=True, indent=4))
```

The locally installed ArchivesSpace version that I am testing on is 2.8.1 
currently.

Thanks for any help.

Cheers,
Tommy

___
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group


Re: [Archivesspace_Users_Group] SOLR/API differences

2021-08-23 Thread RENTON Scott
Brilliant, thanks Andrew. There's quite a good chance that we'd be in a 
position to affect a change across the board, as the instance in question 
covers a single user base and content type.

Much appreciated
Scott



==

Scott Renton

Digital Library Development & Systems

Floor F East

Argyle House

515219


From: archivesspace_users_group-boun...@lyralists.lyrasis.org 
 on behalf of Andrew 
Morrison 
Sent: 23 August 2021 13:30
To: archivesspace_users_group@lyralists.lyrasis.org 

Subject: Re: [Archivesspace_Users_Group] SOLR/API differences

This email was sent to you by someone outside the University.
You should only click on links or attachments if you are certain that the email 
is genuine and the content is safe.

Sorry, forgot to mention, qf can be set in AppConfig[:solr_params] in 
config.rb, but again it applies to all searching, not just API searches.


Andrew.



On 23/08/2021 13:27, Andrew Morrison wrote:

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

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@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group




___
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group


Re: [Archivesspace_Users_Group] SOLR/API differences

2021-08-23 Thread Andrew Morrison
Sorry, forgot to mention, qf can be set in AppConfig[:solr_params] in 
config.rb, but again it applies to all searching, not just API searches.



Andrew.



On 23/08/2021 13:27, Andrew Morrison wrote:


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 



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@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group


___
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
___
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group


Re: [Archivesspace_Users_Group] SOLR/API differences

2021-08-23 Thread Andrew Morrison
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 



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@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
___
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group