IQSS / dataverse

Open source research data repository software
http://dataverse.org
Other
878 stars 487 forks source link

Document search facets in the Search API Guide #9515

Open DS-INRAE opened 1 year ago

DS-INRAE commented 1 year ago

Overview of the Feature Request Document metadataSource facet in the API Seach Guide, maybe alongside other currently undocumented facets.

What kind of user is the feature intended for? API User

What inspired the request? Need to filter Harvested datasets

What existing behavior do you want changed? Add this facet to the examples in the Advanced Search section of the API Seach Guide .

pdurbin commented 1 year ago

@DS-INRA thanks for opening this issue!

For now, to get a list of facets, you can try this:

curl -s "https://dataverse.harvard.edu/api/search?q=*&show_facets=true" | jq '.data.facets[] | keys[]' -r

authorAffiliation_ss
authorName_ss
dvCategory
fileAccess
fileTag
fileTypeGroupFacet
metadataSource
publicationDate
subject_ss

Then, to see a single facet:

curl -s "https://dataverse.harvard.edu/api/search?q=*&show_facets=true" | jq '.data.facets[].metadataSource'

{
  "friendly": "Metadata Source",
  "labels": [
    {
      "Harvard Dataverse": 1445531
    },
    {
      "Harvested": 776606
    }
  ]
}

Let's check that the total count of 776606 matches if we select only harvested:

curl -s "https://dataverse.harvard.edu/api/search?q=*&fq=metadataSource:Harvested" | jq . | head

{
  "status": "OK",
  "data": {
    "q": "*",
    "total_count": 776606,
    "start": 0,
    "spelling_alternatives": {},
    "items": [
      {
        "name": "The French Venus (Catalogue Vol. 2.1)",

Yes, looks good. 😄

By the way @DS-INRA, are you interested in making a pull request? The file to edit is https://github.com/IQSS/dataverse/blob/develop/doc/sphinx-guides/source/api/search.rst and we have tips at https://guides.dataverse.org/en/5.13/developers/documentation.html

DS-INRAE commented 9 months ago

Following this PR, license should also be added in the available facets :)

DS-INRAE commented 4 months ago

Putting this back in "Needed" rather than planned development so someone else may have a go on this if they want/have the time :)