Skip to content

Commit be96f1d

Browse files
committed
improve Search Services docs IQSS#11281
1 parent 13573ea commit be96f1d

3 files changed

Lines changed: 65 additions & 34 deletions

File tree

doc/sphinx-guides/source/api/search.rst

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ metadata_fields string Includes the requested fields for each dataset in the
4141
geo_point string Latitude and longitude in the form ``geo_point=42.3,-71.1``. You must supply ``geo_radius`` as well. See also :ref:`geospatial-search`.
4242
geo_radius string Radial distance in kilometers from ``geo_point`` (which must be supplied as well) such as ``geo_radius=1.5``.
4343
show_type_counts boolean Whether or not to include total_count_per_object_type for types: Dataverse, Dataset, and Files.
44-
search_service string The name of the search service to use for this query. If omitted, the default search service will be used. For available search services, see :ref:`search-services-api`.
44+
search_service string The name of the search service to use for this query. If omitted, the default search service will be used. For available search services, see :ref:`discovering-available-search-services`.
4545
================ ======= ===========
4646

4747
Basic Search Example
@@ -779,15 +779,20 @@ Output from iteration example
779779
CORS
780780
</span>
781781

782-
.. _search-services-api:
782+
.. _search-services:
783783

784-
Search Services API
785-
-------------------
784+
Search Services
785+
---------------
786+
787+
.. _discovering-available-search-services:
788+
789+
Discovering Available Search Services
790+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
786791

787792
To discover available search services and their capabilities, you can use the Search Services API endpoint.
788793
Note: Configurable Search Services are an optional, experimental feature than may evolve faster than other parts of Dataverse.
789794

790-
Endpoint: https://demo.dataverse.org/api/search/services
795+
Example API endpoint: https://demo.dataverse.org/api/search/services
791796

792797
This endpoint returns a list of available search services, including their names, display names, and any additional information about their capabilities.
793798

@@ -804,21 +809,25 @@ Example response:
804809
},
805810
{
806811
"name": "externalSearch",
807-
"displayName": "AI Search for Datasets",
812+
"displayName": "External Search for Datasets",
808813
}
809814
]
810815
}
811816
812-
You can use the `name` values returned by this endpoint in the `search_service` parameter of the main search API to specify which search service to use for a particular query.
817+
You can use the ``name`` values returned by this endpoint in the ``search_service`` parameter of the main search API to specify which search service to use for a particular query.
813818

814819
Using Different Search Services
815-
-------------------------------
820+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
816821

817-
To use a specific search service, include the `search_service` parameter in your search query. For example:
822+
To use a specific search service, include the ``search_service`` parameter in your search query and pass the ``name``. For example:
818823

819824
https://demo.dataverse.org/api/search?q=trees&search_service=externalSearch
820825

821-
This query will use the externalSearch service (assuming it exists) instead of the default search service.
826+
This query will use the ``externalSearch`` service (assuming it exists) instead of the default search service (``solr``).
827+
828+
.. note:: Other search services may not be complete replacements for the included ``solr`` service. For example, they may not support searching for collections or files (just datasets).
822829

823-
.. note:: Other search services may not be complete replacements for the included solr service. For example, they may not support searching for collections or files (just datasets).
830+
Developing Search Services
831+
~~~~~~~~~~~~~~~~~~~~~~~~~~
824832

833+
See :doc:`/developers/search-services` in the Developer Guide.

doc/sphinx-guides/source/developers/search-services.rst

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
Search Services
22
===============
3-
Dataverse now supports configurable search services, allowing developers to integrate new search engines dynamically. This guide outlines the design and provides details on how to use the interfaces and classes involved.
3+
4+
Dataverse supports configurable search services, allowing developers to integrate additional search engines dynamically. This guide outlines the design and provides details on how to use the interfaces and classes involved.
5+
46
Design Overview
57
---------------
68
The configurable search services feature is designed to allow:
9+
710
1. Dynamic addition of new search engines
811
2. Configuration of the Dataverse UI to use a specified search engine
912
3. Use of different search engines via the API
1013
4. Discovery of installed search engines
14+
1115
Key Components
1216
--------------
17+
1318
1. SearchService Interface
1419
^^^^^^^^^^^^^^^^^^^^^^^^^^
15-
The ``SearchService`` interface is the core of the configurable search services. It defines the methods that any search engine implementation must provide.
20+
The ``SearchService`` interface is the core of the configurable search services. It defines the methods that any search engine implementation must provide. (The methods below are accurate as of this writing.)
1621

1722
.. code-block:: java
1823
@@ -28,9 +33,9 @@ The ``SearchService`` interface is the core of the configurable search services.
2833
default void setSolrSearchService(SearchService solrSearchService);
2934
}
3035
31-
The interface allows you to provide a service name and display name, and to respond to the same search parameters that are normally sent to the solr search engine.
36+
The interface allows you to provide a service name and display name, and to respond to the same search parameters that are normally sent to the Solr search engine.
3237

33-
The setSolrSearchService method is used by Dataverse to give your class a reference to the SolrSearchService, allowing your class to perform solr queries as needed. (See the ExternalSearchServices for an example.)
38+
The ``setSolrSearchService`` method is used by Dataverse to give your class a reference to the ``SolrSearchService``, allowing your class to perform Solr queries as needed. (See the ``ExternalSearchServices`` for an example.)
3439

3540
2. ConfigurableSearchService Interface
3641
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -43,15 +48,15 @@ The ``ConfigurableSearchService`` interface extends the ``SearchService`` interf
4348
void setSettingsService(SettingsServiceBean settingsService);
4449
}
4550
46-
The GetExternalSearchServiceBean and PostExternalSearchServiceBean classes provide a use case for this.
51+
The ``GetExternalSearchServiceBean`` and ``PostExternalSearchServiceBean`` classes provide a use case for this.
4752

4853
3. JVM Options for Search Configuration
4954
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5055
Dataverse uses two JVM options to configure the search functionality:
5156

52-
- ``dataverse.search.services.directory``: Specifies the local directory where jar files with search engines (classes implementing the SearchService interface) can be found. Dataverse will dynamically load engines from this directory.
57+
- ``dataverse.search.services.directory``: Specifies the local directory where jar files with search engines (classes implementing the ``SearchService`` interface) can be found. Dataverse will dynamically load engines from this directory.
5358

54-
- ``dataverse.search.default-service``: The serviceName of the service that should be used in the Dataverse UI.
59+
- ``dataverse.search.default-service``: The ``serviceName`` of the service that should be used in the Dataverse UI.
5560

5661
Example configuration:
5762

@@ -65,9 +70,11 @@ Remember to restart your Payara server after modifying these JVM options for the
6570
4. Using Different Search Engines via API
6671
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6772

68-
The loaded search services can be discovered using the /api/search/services endpoint.
73+
The loaded search services can be discovered using the ``/api/search/services`` endpoint.
6974

70-
Queries can be made to different engines by including the optional search_service=<serviceName> query parameter.
75+
Queries can be made to different engines by including the optional ``search_service=<serviceName>`` query parameter.
76+
77+
Use of these endpoints is described for end users in the API Guide under :ref:`search-services`.
7178

7279
Available Search Services
7380
-------------------------
@@ -91,18 +98,23 @@ or
9198
2. PostExternalSearchServiceBean
9299
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93100

94-
These classes implement the ConfigurableSearchService interface.
101+
These classes implement the ``ConfigurableSearchService`` interface.
95102
They make a GET or POST call (respectively) to an external search engine that must return a JSON array of objects with "DOI" and "Distance" keys.
96103
The query sent to the external engine use the same query parameters as the Dataverse search API (GET) or have a JSON payload with those keys (POST).
97104
The results they return are then searched for using the solr search engine which enforces access control and provides the standard formatting expected by the Dataverse UI and API.
98-
The Distance values are used to order the results, smallest distances first.
105+
The distance values are used to order the results, smallest distances first.
106+
107+
They can be configured via two settings each:
108+
109+
- GET
110+
111+
- :GetExternalSearchUrl - the URL to send GET search queries to
112+
- :GetExternalSearchName - the display name to use for this configuration
113+
114+
- POST
99115

100-
They can be cofigured via 2 settings each:
101-
:GetExternalSearchUrl - the URL to send GET search queries to
102-
:GetExternalSearchName - the display name to use for this configuration
103-
104-
:PostExternalSearchUrl - the URL to send POST search queries to
105-
:PostExternalSearchName - the display name to use for this configuration
116+
- :PostExternalSearchUrl - the URL to send POST search queries to
117+
- :PostExternalSearchName - the display name to use for this configuration
106118

107119
As these classes use DOIs as identifiers, they cannot reference collections or, unless file DOIs are enabled, files.
108120
Similar classes, or extensions of these classes could search by database ids instead, etc. to support the additional types.
@@ -113,17 +125,17 @@ Similar classes, or extensions of these classes could search by database ids ins
113125
4. OddlyEnoughSearchServiceBean
114126
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115127

116-
These classes implement the SearchService interface.
128+
These classes implement the ``SearchService`` interface.
117129
They are intended only as code examples and simple tests of the design and are not intended for production use.
118130
The former simply replaces the user query with a query for entities with a db id < 1000. It demonstrates how a class can leverage the solr engine and achieve results solely by modifying/replacing the user query.
119-
The latter only returns hits from the user's query that also have an odd database id. Since the filtering in the class changes the number of total hits available and pagination, this class demonstrates one way a developer can adjust those aspects of the solr response.
131+
The latter only returns hits from the user's query that also have an odd database id. Since the filtering in the class changes the number of total hits available and pagination, this class demonstrates one way a developer can adjust those aspects of the Solr response.
120132

121133
Notes
122134
-----
123135

124-
1. Unless you use the solr engine to provide access control, you must implement proper access control in your search engine
125-
2. The design currently limits search results to be in the format returned by solr and the hits are expected to be collections, datasets, or files - other classes are not supported.
126-
3. Search services could be designed to completely replace solr or to just support certain use cases (e.g. the external search classes only handling datasets).
136+
1. Unless you use the Solr engine to provide access control, you must implement proper access control in your search engine
137+
2. The design currently limits search results to be in the format returned by Solr and the hits are expected to be collections, datasets, or files - other classes are not supported.
138+
3. Search services could be designed to completely replace Solr or to just support certain use cases (e.g. the external search classes only handling datasets).
127139
4. While search services can be deployed as independent jar files, they currently import multiple Dataverse classes and, unlike exporters, cannot be built using just the Dataverse SPI.
128-
5. As with other experimental features, we expect the SearchService interface may change over time as we learn about how people use it. Please keep in touch if you are developing search services.
140+
5. As with other experimental features, we expect the ``SearchService`` interface may change over time as we learn about how people use it. Please keep in touch if you are developing search services.
129141

doc/sphinx-guides/source/installation/config.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,16 @@ This setting allows admins to highlight a few of the 1000+ CSL citation styles a
35663566
These will be listed above the alphabetical list of all styles in the "View Styled Citations" pop-up.
35673567
The default value when not set is "chicago-author-date, ieee".
35683568

3569+
dataverse.search.services.directory
3570+
+++++++++++++++++++++++++++++++++++
3571+
3572+
Experimental. See :doc:`/developers/search-services`.
3573+
3574+
dataverse.search.default-service
3575+
++++++++++++++++++++++++++++++++
3576+
3577+
Experimental. See :doc:`/developers/search-services`.
3578+
35693579
.. _dataverse.cors:
35703580

35713581
CORS Settings

0 commit comments

Comments
 (0)