SUIT (the library that powers the search interface) also supports limited functionality with Elastic and Solr.
- A read only public elastic index.
- CORS enabled instance (more info here).
In configuration.properties.js:
-
Set
searchEngineType
toelastic
:searchEngineType: "elastic"
-
Set
baseUri
to point to the elastic instance, adding the index and the search handler:baseUri: "http://my.elastic.instance:9200/myIndex/_search"
-
Create a request handler:
- The
defType
needs to beedismax
. - The response type needs to be
json
(wt
) . - In
df
andqf
you need to specify the fields of the search separated by a space.
<!-- A request Handler for the integration with the SUIT module --> <requestHandler name="/mySearch" class="solr.SearchHandler"> <lst name="defaults"> <str name="echoParams">explicit</str> <str name="wt">json</str> <str name="indent">true</str> <str name="defType">edismax</str> <str name="df">id author date other_field</str> <str name="qf">id author date other_field</str> </lst> </requestHandler>
- The
-
make solr read-only adding a proxy or disabling components.
-
Enable CORS.
In configuration.properties.js:
-
Set
searchEngineType
tosolr
:searchEngineType: "solr"
-
Set
baseUri
to point to the solr instance, adding the index and the search handler:baseUri: "http://my.solr.instance:8983/solr/myIndex/mySearch"
-
Add
customOptions
in theALL
property (ALL.customOptions
):customOptions: { customId: String, mappings: Object, facets: Object }
-
Set customId (optional), if you need other field to work as the document id:
customId: "alternative_id_field"
-
Add mappings (required), the valid fields are:
- title
- uri
- teaser
- text
- previewImageUri
- thumbnailImageUri
mappings: { title: "field_of_title", teaser: "field_of_teaser", text: "field_of_text" },
-
Add facets (optional), if you want to add facets you need to make sure the fields are searchable. The facets object is an array of objects with two properties (
displayName
andfield
)- displayName: The name of the facet in the left side menu.
- field: The name of the field used to generate the facets (this field needs to exist in the elastic index and needs to be searchable).
facets: [ { displayName: "Authors", field: "author_str" }, { displayName: "Second Facet", field: "second_field_to_get_facets_str" } ]
-
-
Add sortable fields (required):
You can configure this fields on
SearchUISearchPage.sortableFields
, its a array of string with the field names.These fields are included in the sort menu, they need to exist in the mappings object (
ALL.customOptions.mappings
)sortableFields: [ "creation_date", "author" ]
These fields need to be searchable.