diff --git a/doc/release-notes/11331-search-fileSizeInBytes.md b/doc/release-notes/11331-search-fileSizeInBytes.md new file mode 100644 index 00000000000..94231e59aa2 --- /dev/null +++ b/doc/release-notes/11331-search-fileSizeInBytes.md @@ -0,0 +1 @@ +The User Guide has been updated to explain how to search for files above or below a certain size by entering a range query such as `fileSizeInBytes:[1048576 TO *]` in the search box. The Search API Guide now covers the same `fileSizeInBytes` field for use with the `fq` parameter. See [the guides](https://guides.dataverse.org/en/6.13/user/find-use-data.html#file-size-search) and #11331. diff --git a/doc/sphinx-guides/source/api/search.rst b/doc/sphinx-guides/source/api/search.rst index eea125b76b7..acd91cd73ce 100755 --- a/doc/sphinx-guides/source/api/search.rst +++ b/doc/sphinx-guides/source/api/search.rst @@ -722,6 +722,29 @@ Below is an example of searching across a date range of Dataverse collections, d `https://demo.dataverse.org/api/search?q=*&per_page=1000&sort=date&order=asc&q=*&fq=dateSort:[2018-01-01T00\:00\:00Z+TO+2019-01-01T00\:00\:00Z] `_ +.. _search-file-size: + +File Size Search Example +------------------------ + +Files are indexed with a ``fileSizeInBytes`` field containing the size of the file in bytes. You can use this field with the ``fq`` parameter to search for files above or below a certain size. Because only files have this field, you should (but don't strictly have to) also pass ``type=file``. + +Below is an example of searching for files that are 1 MB (1048576 bytes) or larger. The ``*`` means there is no upper bound. + +`https://demo.dataverse.org/api/search?q=*&type=file&fq=fileSizeInBytes:[1048576+TO+*] `_ + +To search for files smaller than a certain size, leave the lower bound open instead. Below is an example of searching for files up to 1 MB. + +`https://demo.dataverse.org/api/search?q=*&type=file&fq=fileSizeInBytes:[*+TO+1048576] `_ + +Square brackets (``[`` and ``]``) include the values at each end of the range. To exclude them, use curly braces (``{`` and ``}``) instead. Below is an example of searching for files between 1 MB and 10 MB (10485760 bytes), not including files that are exactly either size. + +`https://demo.dataverse.org/api/search?q=*&type=file&fq=fileSizeInBytes:{1048576+TO+10485760} `_ + +These range queries are not limited to the API. The search box in the web interface passes your query to the search index in the same way, so you can type ``fileSizeInBytes:[1048576 TO *]`` directly into it to find files of 1 MB or larger. See :ref:`file-size-search` in the User Guide. + +Note that in the search results themselves, the size of each file is returned as ``size_in_bytes`` rather than ``fileSizeInBytes``. + .. _iteration-example: Iteration diff --git a/doc/sphinx-guides/source/user/find-use-data.rst b/doc/sphinx-guides/source/user/find-use-data.rst index 8e65108d680..de9a84699e6 100755 --- a/doc/sphinx-guides/source/user/find-use-data.rst +++ b/doc/sphinx-guides/source/user/find-use-data.rst @@ -39,6 +39,13 @@ enter search terms for Dataverse collections, dataset metadata (citation and dom metadata. If you are searching for tabular data files you can also search at the variable level for name and label. To find out more about what each field searches, hover over the field name for a detailed description of the field. +.. _file-size-search: + +File Size Search +---------------- + +You can search for files above or below a certain size by entering a range query for the ``fileSizeInBytes`` field in the search box. For example, ``fileSizeInBytes:[1048576 TO *]`` finds files that are 1 MB (1048576 bytes) or larger, and ``fileSizeInBytes:[* TO 1048576]`` finds files up to that size. See :ref:`search-file-size` in the API Guide for more examples. + .. _geospatial-search: Geospatial Search