Loading...
 
Skip to main content

History: Api Search Doc

Source of version: 4 (current)

Copy to clipboard
{DIV(class="content-section d-none" id="search-lookup")}
!!! Perform a lookup in the search index

Perform a lookup in the search index to find objects matching specific filters and sorting options.

{TABS(name="doc-search-lookup" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - search" colors="http" theme="default")}
https://example.com/api/search/lookup
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - search" colors="http" theme="default")}
curl --request GET \
     --url "https://example.com/api/search/lookup" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --data-urlencode "filter=filter[title]=plugin" \
     --data-urlencode "format={object_id} {title}" \
     --data-urlencode "sort_order=title_desc" \
     --data-urlencode "maxRecords=5" 

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - search" colors="php" theme="default")}
<?php

$baseUrl = 'https://example.com/api/search/lookup';

$params = [
    'filter' => 'filter[title]=plugin',
    'format' => '{object_id} {title}',
    'sort_order' => 'title_desc',
    'maxRecords' => 5
];

$url = $baseUrl . '?' . http_build_query($params);

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($http_code === 200) {
    $data = json_decode($response, true);
    print_r($data);
} else {
    echo 'Error: HTTP status code ' . $http_code;
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - search" colors="javascript" theme="default")}
const params = new URLSearchParams({
  filter: 'filter[title]=plugin',
  format: '{object_id} {title}',
  sort_order: 'title_desc',
  maxRecords: '5'
});

fetch('https://example.com/api/search/lookup?' + params.toString(), {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer <API_TOKEN>'
  }
})
.then(res => {
  if (!res.ok) throw new Error("HTTP " + res.status);
  return res.json();
})
.then(data => {
  console.log(data);
})
.catch(err => {
  console.log('Fetch error: ' + err.message);
});

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - search" colors="json" theme="default")}
{
    "title": "Lookup Result",
    "resultset": {
        "count": 4,
        "offset": 0,
        "maxRecords": 5,
        "result": [
            {
                "object_type": "file gallery",
                "object_id": "10",
                "parent_id": "3",
                "title": "10 <b class=\"highlight_word highlight_word_0\">plugin</b> error"
            },
            {
                "object_type": "wiki page",
                "object_id": "plugin error",
                "parent_id": null,
                "title": "<b class=\"highlight_word highlight_word_0\">plugin</b> error <b class=\"highlight_word highlight_word_0\">plugin</b> error"
            },
            {
                "object_type": "wiki page",
                "object_id": "plugin-test",
                "parent_id": null,
                "title": "<b class=\"highlight_word highlight_word_0\">plugin</b>-test <b class=\"highlight_word highlight_word_0\">plugin</b>-test"
            },
            {
                "object_type": "wiki page",
                "object_id": "test-plugin-argument",
                "parent_id": null,
                "title": "test-<b class=\"highlight_word highlight_word_0\">plugin</b>-argument test-<b class=\"highlight_word highlight_word_0\">plugin</b>-argument"
            }
        ]
    }
}
{CODE}
{DIV}

{TABS}

!!!! Parameters

* __filter[]__ ''array'' ~~#fe0000:*~~: Filter index fields and content.
* __format__ ''string optional'' : The format of the response data. e.g. ~~#9011ff:__{object_id} {title}__~~
* __sort_order__ ''string optional'': The sort order of the results. Possible values are:
** ~~#9011ff:__title_asc__~~ : Sort by title, A to Z.
** ~~#9011ff:__title_desc__~~ : Sort by title, Z to A.
* __offset__ ''integer optional'' : The record offset to start returning results from.
* __maxRecords__ ''integer optional'' : The maximum number of records to return.

{DIV}


{DIV(class="content-section d-none" id="search-process-queue")}
!!! Process incremental index queue update

Process incremental index queue update

{TABS(name="doc-search-process-queue" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - search" colors="http" theme="default")}
https://example.com/api/search/process-queue
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - search" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/search/process-queue" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --data-urlencode "batch=10" 
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - search" colors="php" theme="default")}
<?php

$baseUrl = 'https://example.com/api/search/process-queue';
$params = ['batch' => 10];
$url = $baseUrl . '?' . http_build_query($params);

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_code === 200) {
    $data = json_decode($response, true);
    print_r($data);
} else {
    echo 'Error: HTTP status code ' . $http_code;
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - search" colors="javascript" theme="default")}
const params = new URLSearchParams({ batch: '10' });

fetch('https://example.com/api/search/process-queue?' + params.toString(), {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer <API_TOKEN>'
  }
})
.then(res => {
  if (!res.ok) throw new Error("HTTP " + res.status);
  return res.json();
})
.then(data => {
  console.log(data);
})
.catch(err => {
  console.log('Fetch error: ' + err.message);
});


{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - search" colors="json" theme="default")}
{
  "title": "Process Update Queue",
  "stat": null,
  "queue_count": 0,
  "batch": 10
}
{CODE}
{DIV}

{TABS}

!!!! Parameters

* __batch__ ''integer'' ~~#fe0000:*~~: The number of records to process.

{DIV}


{DIV(class="content-section d-none" id="search-rebuild")}
!!! Run search index rebuild

Run search index rebuild

{TABS(name="doc-search-rebuild" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - search" colors="http" theme="default")}
https://example.com/api/search/rebuild
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - search" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/search/rebuild" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --data-urlencode "loggit=2" 
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - search" colors="php" theme="default")}
<?php

$baseUrl = 'https://example.com/api/search/rebuild';
$params = ['loggit' => 2];
$url = $baseUrl . '?' . http_build_query($params);

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_code === 200) {
    $data = json_decode($response, true);
    print_r($data);
} else {
    echo 'Error: HTTP status code ' . $http_code;
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - search" colors="javascript" theme="default")}
const params = new URLSearchParams({ loggit: '2' });

fetch('https://example.com/api/search/rebuild?' + params.toString(), {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer <API_TOKEN>'
  }
})
.then(res => {
  if (!res.ok) throw new Error("HTTP " + res.status);
  return res.json();
})
.then(data => {
  console.log(data);
})
.catch(err => {
  console.log('Fetch error: ' + err.message);
});

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - search" colors="json" theme="default")}
{
    "title": "Rebuild Index",
    "formattedStats": null,
    "search_engine": "MySQL",
    "search_version": "8.0.40",
    "search_index": "index_68f4e5c8c4ea5",
    "fallback_search_engine": "",
    "fallback_search_version": "",
    "fallback_search_index": "",
    "queue_count": 0,
    "log_file_browser": "/temp/Search_Indexer_mysql_tiki.log",
    "fallback_log_file_browser": "/temp/Search_Indexer_mysql_tiki.log",
    "log_file_console": "/temp/Search_Indexer_mysql_tiki_console.log",
    "fallback_log_file_console": "/temp/Search_Indexer_mysql_tiki_console.log",
    "lastLogItemWeb": "2025-05-19T21:48:04+00:00 INFO (6): Execution time: < 1 sec\n",
    "lastLogItemConsole": "[2025-10-19T13:21:25.804120+00:00] indexer.INFO:   total fields used in the mysql search index: 231 [] []\n",
    "isAjax": false,
    "showForm": false,
    "unified_last_rebuild": 1760880072
}
{CODE}
{DIV}

{TABS}

!!!! Parameters

* __loggit__ ''integer'' ~~#fe0000:*~~: Log index rebuild process to file. Possible values are:
** ~~#9011ff:__0__~~ : no logging
** ~~#9011ff:__1__~~ : log to Search_Indexer.log
** ~~#9011ff:__2__~~ : log to Search_Indexer_console.log

{DIV}
Show PHP error messages