List endpoints support text searches. You can filter results by specifying text fragments to search for in the data.
This feature uses Apache Lucene to perform a text search on certain indexed properties,
determined by the API and the database configuration.
Usually, label properties such as rdfs:label and skos:prefLabel will be indexed.
Use the search query parameter to specify the text fragments to search for.
You can search for multiple terms by separating each term with a space. If you do, the list endpoint will only return results whose text contains all the specified terms.
You can use the wildcard character * in a text fragment to denote an arbitrary string of characters.
You can customise your search request by supplying the following parameters with the search parameter:
| Parameter | Description |
|---|---|
fuzzy |
Performs a fuzzy text search for the supplied text fragments. |
raw-search |
Treats the supplied text as a raw Lucene query and directly performs the query. |
sort-search |
Orders the results of the text search based on their Lucene query score. |
disjoint-search |
If you provide multiple search parameters, combines them as a disjunction instead of a conjunction. |
These parameters are flags, so you don’t need to supply a value for them.
If you use raw-search to request a raw search, your search parameter value should be written in the Lucene query syntax.
If you use sort-search to request a sorted search, the closest matches for the terms given by the search parameter
will appear first in the list of results.
The query score is evaluated by Lucene.
If you use disjoint-search to request a disjoint search,
Sapi-nt connects the search terms given by separate query parameters with the Lucene OR operator in the generated query.
Note that this only applies when you request multiple text search fields.
You can request a text search on related resources by supplying the searchPath parameter.
The parameter value should be a .-separated property path from the root resource to the set of related resources
that you want to treat as the subject of the text search.
Then you can specify the search terms with the search parameter as usual.
A text search path can be used in conjunction with the usual search modifiers.
This approach may be useful in cases where the root resources returned by the endpoint don’t have any text-indexed properties, but their related resources do.
This feature is only available when the endpoint has defined views.
The Jena text indexer creates a Lucene document for each indexed resource, and the document has a single field comprised by any number of RDF property values. As such, it’s not usually possible to query for a specific property.
However, the database may use a custom text indexer (eg. ppd-index), to maintain a multi-field text index, where each field corresponds to a certain RDF property. In this case, it’s possible to query each indexed property individually. This section explains how to request text searches on properties that are indexed in this way.
You can mix both the root search (using search request parameter) and the fielded search (using search-{prop}
request parameter) in the same request. Note that fuzzy and raw searches are all or nothing, meaning that if fuzzy
or raw-search flags are present then all the search parameters will apply fuzzy or a raw search respectively.
If you supply both a search-{prop} parameter and a searchPath parameter,
the text search will be performed on the given property of the resources referenced by the given search path.
The following examples show some possible usages of the text search API:
| Query | Meaning |
|---|---|
search={term} |
Return only results whose text contains the given term. |
search={term1%term2} |
Return only results whose text contains the given terms. |
search={term}&fuzzy |
Return only results whose text is similar to the given term. |
search={query}&raw-search |
Return the results of the given Lucene query. |
searchPath={path}&search={term} |
Return only results for which the related resource located by the given path contains the given term. |
search-{prop}={term} |
Return only results whose property contains the given term. |