Skip to content

Configuration of the API

Patrick van Efferen edited this page Nov 18, 2020 · 2 revisions

Configuration of the service

The service, which is written in the PHP micro framework Slim, does all the fancy rewriting and query boosting. The settings should be added in the environment folder. The service itself can be found in the folder service/mus starting from the drupal root. There is not much that can be changed in the service without a very good understanding of Solr.

Api key configuration.

The catch service can be used with an API key in order to be able to make some documents private based on a field value. In order to use this functionality, the private field component should be used. The jar file needed in Solr can be downloaded from the github project, which can be found at the following url: https://github.com/jurcello/SolrPrivateFieldComponent The usage of this Solr component is as follows:

Copy the jar file in the lib dir of your solr core. Then add the following snippet to the solrconfig.xml:

  <searchComponent name="privateField" class="nl.triquanta.solr.component.PrivateFieldComponent">
    <str name="allowedFields">allowedField1, allowedField2</str>
    <str name="privateField">fieldContainingPrivateInformation</str>
    <str name="publicValue">full</str>
  </searchComponent>

There are 3 parameters in this declaration:

1. allowedFields: the fields that may be returned if the document is regarded private.
2. privateField: the field in the index in which the information about the privacy of the document is stored.
3. publicValue: the value of the privateField for which the document is regarded public.

After declaration of the component, add it to the components list of the request handler. For example:

  <requestHandler name="myExampleHandler" class="solr.SearchHandler">
    <!-- default values for query parameters -->
    <lst name="defaults">
    	.. all the defaults you like
    </lst>
    <arr name="components">
      <str>query</str>
      <str>facet</str>
      <str>mlt</str>
      <str>privateField</str>
      <str>highlight</str>
      <str>stats</str>
      <str>debug</str>
    </arr>
  </requestHandler>

Example

Assume we have the following documents:

document1:
	title: my secret document
	id: 200
	secret: secret info which may not be returned
	access: private

document2: 
	title: my public document
	id: 201
	secret: information which is not really secret
	access: full

And we have the following component definition:

  <searchComponent name="privateField" class="nl.triquanta.solr.component.PrivateFieldComponent">
    <str name="allowedFields">title</str>
    <str name="privateField">secret</str>
    <str name="publicValue">full</str>
  </searchComponent>

Using this definition, if we do search request and let all fields be returned, we get the following result:

results:
	document1:
		title: my secret document
	document2: 
		title: my public document
		id: 201
		secret: information which is not really secret

Clone this wiki locally