Search Query
Query description
The Search Query is sent when searching in Datafari and pressing the “Enter” key or clicking on the magnifying glass:
GET https://[DATAFARI_BASE_URL]/Datafari/rest/v2.0/search/select?parameters
Example https://datafariui.datafari.com/Datafari/rest/v2.0/search/select?parameters
Query parameters:
Parameter | Value | Description | Data Type |
---|---|---|---|
q | User input (default: *:*) | The user input from search bar. When the user does not enter any term in the search bar, use the default value “*:*” to retrieve all documents indexed in Datafari. | String |
fl | List from ui-config.json | Used to display items on the search page about the document, like title, preview content, url, etc... The list of values from "queryParams": { "fields": [ ] } in the configuration file: ui-config.json. The default values in this file are: "queryParams": {
"fields": [
"title",
"url",
"id",
"extension",
"preview_content",
"last_modified",
"crawl_date",
"author",
"original_file_size",
"emptied",
"repo_source"
]
}, | String |
sort | score desc | Fixed value to sort the result list of documents. | String |
q.op | AND | Fixed value that configure the type of search in Solr. | String |
rows | 10 | Number of documents retrieved by the query. Fixed value. | number |
start | Computed value | Is used to retrieve next page of result list. The search query must be sent with a value computed as follow: page_index * rows. Starts with 0. To have the first result page start=0, then second page is start=1*10, etc… | number |
aggregator | From ui-config.json | The value of this parameter must be retrieved from this object in the ui-config.json file: “aggregator” value from searchBar.suggesters[x].type=”BASIC”.aggregator. |
boolean |
facet | true | Always true for filtering results with facet selections. | boolean |
facet.field | {!ex=field_name}field_name made from ui-config.json | This parameter is used for result arrangement into categories (Solr functionality). It is made with all objects of type FieldFacet and the object of type HierarchicalFacet in ui-config.json: All objects With the current ui-config.json content the parameters to generate are: &facet.field={!ex=author}author
&facet.field={!ex=repo_source}repo_source
&facet.field={!ex=extension}extension
&facet.field={!ex=language}language
&facet.field={!ex=urlHierarchy}urlHierarchy | String multiple |
facet.query | {!key=id_index}query made from ui-config.json | This parameter is used for result arrangement into categories (Solr functionality). It is made with one object of type QueryFacet in ui-config.json: The object
| String multiple |
Header Parameters:
Nothing
Request Body Parameters:
Nothing
Path Parameters:
Nothing
Response description
A JSON response containing the list of documents found. All needed to display the result is in this response.
Here are the 5 main objects:
spellcheck
: no use.
response
: the documents and their information.
responseHeader
: no use.
highlighting
: used to display highlighted terms in the preview content.
facet_counts
: used to fill the facets (7-Facets).
facet_fields : This object is linked to "FieldFacet" objects in ui-config.json. It is used to fill the corresponding facets on the result page (7-Facets). Each item of this object is as follow:
“field”: [ (String,number) For the "field" Facet. A table with couples of [label,number].
“label1”, number_for_label1,
“label2”, number_for_label2,
etc...
],
“field” will have the value of “field” attribute of the "FieldFacet" object in ui-config.json (i.e. left[x].type="FieldFacet")). For example, it is "extension" with this defined in ui-config.json:
"left": [ ...
{
"type": "FieldFacet",
"title": "Extension",
"field": "extension",
"op": "OR",
"minShow": 3,
"maxShow": 15
}, ...
]
Examples
For these examples, we use https://demo.datafari.com/ to illustrate another configuration and see how parameters can vary. See below its ui-config.json:
Empty search
Here is the default request sent to the Datafari API for an empty input in the search bar:
https://datafariui.datafari.com/Datafari/rest/v2.0/search/select q: *:* fl: title,url,id,extension,preview_content,last_modified,crawl_date,author,original_file_size,emptied,repo_source sort: score desc q.op: AND rows: 10 start: 0 aggregator: facet: true facet.field: {!ex=author}author facet.field: {!ex=repo_source}repo_source facet.field: {!ex=extension}extension facet.field: {!ex=entity_phone_present}entity_phone_present facet.field: {!ex=entity_special_present}entity_special_present facet.field: {!ex=language}language facet.field: {!ex=urlHierarchy}urlHierarchy facet.query: {!key=date__lastmodified_facet_0}last_modified:[NOW/DAY TO NOW] facet.query: {!key=date__lastmodified_facet_1}last_modified:[NOW/DAY-7DAY TO NOW/DAY] facet.query: {!key=date__lastmodified_facet_2}last_modified:[NOW/DAY-30DAY TO NOW/DAY-8DAY] facet.query: {!key=date__lastmodified_facet_3}last_modified:([1970-09-01T00:01:00Z TO NOW/DAY-31DAY] || [* TO 1970-08-31T23:59:59Z]) facet.query: {!key=date__lastmodified_facet_4}last_modified:[1970-09-01T00:00:00Z TO 1970-09-01T00:00:00Z]
Pay attention to the bold parameter in the query. This is the only parameter that will be modified when searching for one or several words.
See also facet.field
parameters. The entity_phone_present
and entity_special_present
values reflect the new facets present in this Datafari (refer to the ui-config.json provided above).
Response:
In the detailed response below, you find the first 10 documents in the response.docs
objects with response.numFound=14
. This last value is used to display the number of pages. 10 documents because of the default number of rows to be retrieved, which you will find the value in parameter rows
in the query.
The “ids” in highlighting
objects are empty, so the preview_content is displayed above.
Term(s) search
Except for the “q” parameter, an empty search is not different from a search with terms. So we don’t repeat the full query here, but we specify the “q” parameter: q=watercraft.
Response:
In the detailed response below, you find the first 10 documents in the response.docs
objects with response.numFound=49
In the detailed response below, there are “ids” in the highlighting
objects that are filled in and others that are not. When highlighting is available, the text displayed is the concatenation of the texts present in this object (exactContent
and content_en
). Otherwise, it is the preview_content
.