1

I'm learning to use the CROSSREF rest API, and want to search for all DOI's with affiliation to a given university. How do I create a multi word search query for AND, not AND/OR?

There are over 100 million DOI's on CrossRef, but only 8217730 have authors affiliation metadata.

https://api.crossref.org/works?sample=10&filter=has-affiliation:true

Now if I want to query search for affiliations with "University of Southern Mississippi," I could use mississippi+university+southern, but this return AND/OR the three words.

I want only affiliations with all three words.

https://api.crossref.org/works?sample=10&query.affiliation=mississippi+university+southern

This returns all with the word university or southern or mississippi

CrossRef field query instructions are here https://github.com/CrossRef/rest-api-doc#field-queries and a github comment about the topic is here https://github.com/CrossRef/rest-api-doc/commit/a4d047e0d1556e80aaab0f4b5aae420da2a99ea2 and here https://github.com/CrossRef/rest-api-doc/issues/170

adm
  • 354
  • 5
  • 17

2 Answers2

1

The problem is the sample parameter in your URI. The sample parameter gives you random result.

Being able to select random results is useful for both testing and sampling. You can use the sample parameter to retrieve random results. API description for Sample

So if you want to query just for all results of '' then use the URI without the sample part. Like:

https://api.crossref.org/works?query.affiliation=mississippi+university+southern
Roman Baum
  • 11
  • 2
  • 1
    I don't think this answers the question - the problem is that the CrossRef API does not support Boolean operators, it uses scores so I don't think you can get do what OP is trying with the REST API. – user1222447 Sep 28 '21 at 06:23
0

CrossRef API doesn’t support Boolean operators. The query.affiliation path returns multiple results with scores. You will see the highest score in the resulting json has a key: value out of ‘chosen: true’.

I believe that they have recently transitioned from Solr to Elasticsearch - https://www.crossref.org/blog/behind-the-scenes-improvements-to-the-rest-api/ - which supports Boolean search - https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html - but I’m not sure how to use it on CrossRef API endpoints not if you even can.

user1222447
  • 113
  • 1
  • 1
  • 7