Build_Search_index
Back to ListDescription: Build Google search index for a web site
FileMaker Prototype:
Set Variable [$res; ACF_Run("Build_Search_index")]
Category: WEB
The Build_Search_Index function generates a Google search index JSON from HTML documents stored in a specified document table, ready for upload to your website. This table must contain the following fields: a text version of the document, an ID (primary key), a title, and the document name (slug). Adjust the function's data references (field names, table name, and base URL) to suit your application.
The generated search index is formatted according to Google’s specifications, producing a file named Documents.json. This file can be uploaded to your website and configured in Google Search Console to enable search functionality for your document collection.
Included in the library, this function serves as a customizable template to fit your specific indexing needs.
Example
Set Variable [$res; ACF_Run("Build_Search_Index")]
Result: (Body text shortened for readability)
[
{
"body": "# Introduction\n\nFunction source:
function Build_Search_index ()
string base = "https://horneks.no/manuals/ACF/";
array string aID, aTitle, aText, aSlug;
string sql = "SELECT PrimaryKey, Title, DocumentText, slug_filename FROM ACF_Documents
INTO :aID, :aTitle, :aText, :aSlug";
string res = executeSQL ( sql );
string url;
JSON index;
int i;
for (i=1, sizeof(aID))
url = base + aSlug[i];
index["[]"] = JSON("id", aID[i], "title", aTitle[i], "body", aText[i], "url", url);
end for
int x;
x = open (Preferences::HTML_Folder + "/"+"documents.json","w");
write ( x, string (index));
close (x);
return "OK";
end
\nA Brief History of the ACF Language....\n", "id": "75AAA2C8-59BD-4541-8742-6E15EDDF5310", "title": "Introduction to the Advanced Custom Functions FileMaker Plugin", "url": "https://horneks.no/manuals/ACF/introductiontotheadvancedcustomfunctionsfilemakerplugin.html" }, { "body": "# Programming Basics\n\nIn this chapter, you will find the basic constructs and some basics for programming in the ACF-language.....\n\n", "id": "01F08753-23CA-4213-A980-0B0E5F6229FE", "title": "Programming Basics", "url": "https://horneks.no/manuals/ACF/programmingbasics.html" }, { "body": "# Literals\n\nThere are five kinds of literals in ACF:\n\n- String literals: .....\n\n", "id": "8C03D6BD-EBD3-48E3-B4AE-E3B078876556", "title": "Summary of Data types", "url": "https://horneks.no/manuals/ACF/summaryofdatatypes.html" }, ... ]
This JSON structure can contain many more documents and is ideal for large collections where a comprehensive search index is needed. 