- Print
- DarkLight
- PDF
The SOLR Search API will be disabled by default with the release of version 12, but can be re-enabled via configuration. Please note that re-enabling the SOLR search API will have major negative impacts on server performance.
The Constellio team is developing a new search API via REST API V2 for release this fall. The new API will maintain the features deemed most important of the SOLR Search API, but simplify the calls and return formats. The SOLR Search API will remain available until June 30, 2025, after which Constellio reserves the right to remove it from the product completely. Any new development will be done in the new search API.
Constellio search service settings
Based on the Apache Solr service, Constellio's search web service allows developers to perform search queries programmatically.
Search parameters are sent to the search engine using parameters in the service URL.
Here is the URL of the service http://<host>:<port>/constellio/select
Here is an example :http://<host>/constellio/select?token=254de7d9-89d2-42f7--63&serviceKey=38fhhdf_df3493f&fq=schema_s:document*&q=québec&indent=true&rows=10&wt=json
Setting: DefType (recommended)
Indicates the search type. Always use this one:
defType=edismax
The qf parameter indicates the search fields and allows you to “boost” a particular field if the “^” criterion is used. In this example we search on the default search field (content_txt_fr and we “boost” the documents which contain the keywords searched in their title):
qf=content_txt_fr title_t_fr^20.0
Setting: FL (recommended)
Allows you to indicate the fields to display.
fl=<fields1>,<fields2>
Leave blank to display all fields.
Attention ! In production, only ask the server for the fields displayed to the user. Some (content_*) contain a lot of data and slow down the search. Instead, use highlighting (hl parameter, lower) to return only the relevant extract of the content.
Setting: Rows (recommended)
Number of results to return.
rows=15
Default: 10
It is suggested not to return more than twenty results.
Setting: Start (recommended)
Default: 0
Allows you to specify the starting position in the results.
Useful for pagination. The numFound field in the response header allows you to obtain the total number of results obtained.
Setting: Q (recommended)
In order to specify the search terms and expressions, we use the 'q' parameter as follows:
q=test
Using Solr syntax allows you to apply selection criteria to search expressions. For example, we have:
At least one word:
q=(pamela OR Thursday OR documentation)
All the words :
q=(pamela AND Thursday AND documentation)
Exact expression:
q="documentation given to pamela on Thursday"
We can also use a few operators to spice up the results obtained:
- Phrase: “table of contents”
- “Wildcard”/frimes: One character: p?mela
- Prefix: pam*
- Suffix: *mela
- Blurry: pabela~
- Negation: -Friday
Setting: Q.OP
Specifies the default Boolean operator (AND | OR). Use “AND”:
q.op=AND
Setting: FQ
Allows you to add filters to the search.
fq=<field name>:<value>
Example (to return documents only):
fq=schema_s:document*
Several “fq” parameters can be specified. The filters will add up.
Setting: Sort
This setting allows you to sort search results in ascending/decreasing order. According to the following formula:
sort=<field name> <ASC | DESC>
Sorting varies depending on the type of fields. Use the *_sort_s or _da (date) fields preferably.
Setting: Indent
indent=<true|false>
Useful for formatting code and making it more readable.
Setting : HL
Allows you to highlight.
Enabling highlighting:
hl=true
Choice of field(s) for highlighting. “parsedContent_t_fr” allows you to highlight the content extracted from the document. A must-have.
hl.fl=parsedContent_t_fr
Excerpt size in characters
hl.fragsize=150
Number of extracts:
hl.snippets=2
Setting: SPELLCHECK
Advance. Allows you to enable spell check for the user's query.
Activation: qt=/spell&spellcheck=on
The suggestion is activated if necessary, and is offered at the end of the response.
Setting : FACET
Advance. Allows you to construct facets on the search.
Activation:
facet=true
Minimum number of results to display a facet (default 0)
facet.mincount=1
Choice of fields for the facet:
*Choose only “*_s” type fields.
facet.field=<fields1>
facet.field=<fields2>
Answer
Important fields
Identifier: id
Content type: schema_s
Modified date: modifiedOn_dt
Collection: collection_s
Title: title_*
Content: content_*
Version: version _s
Field types
Here are the main types of fields available:
*_s: Exact string (sensitive to case and accents)
*_ss: String, but with multiple values
*da: date
*_t_fr: Fields analyzed in French. Not sensitive to case and accents, but ignores certain characters (separators, suffixes for plural, etc.)
*_sort_s: Perfect for sorting
See also
Official Solr documentation about queries