Rename a Fulltext Search View
This page explains how to rename a fulltext search view.
- Web Console
- REST API
- CLI
- Python SDK
- JavaScript SDK
Follow these instructions to rename a fulltext search view using the GDN console web UI.
- Log in to your Macrometa account.
- Click Data > Search Views.
- Click Rename next to the search view for which you want to change the name.
- Enter a new name in the field and then click Rename.
- Click Yes to confirm.
Use our interactive API Reference with code generation in 18 programming languages to Rename a Fulltext Search View.
Use our command line interface to Rename a Fulltext Search View.
# Import libraries
from c8 import C8Client
# Define constants
URL = "play.paas.macrometa.io"
GEO_FABRIC = "_system"
API_KEY = "<API Key>" # Change this to your API key.
SEARCH_VIEW_NAME = "SearchView" # Change this to the search view you want to rename.
NEW_SEARCH_VIEW_NAME = "NewSearchView" # Change this to the new name for the search view.
# Authenticate with API key.
client = C8Client(protocol='https', host=URL, port=443, apikey=API_KEY, geofabric=GEO_FABRIC)
# Check if fulltext search view exists
list_views = client.list_all_views()
if any(view.get('name') == SEARCH_VIEW_NAME for view in list_views):
# Rename the fulltext search view if it exists
response = client.rename_view(SEARCH_VIEW_NAME, NEW_SEARCH_VIEW_NAME)
print(f"Successfully renamed search view from '{SEARCH_VIEW_NAME}' to '{NEW_SEARCH_VIEW_NAME}'.")
else:
print(f"Search view '{SEARCH_VIEW_NAME}' does not exist.")
// Connect to GDN.
const jsc8 = require("jsc8");
const client = new jsc8({url: "https://play.paas.macrometa.io", apiKey: "<API Key>", fabricName: "_system"});
console.log("Connected to GDN.");
const searchViewName = "SearchView"; // Replace with the name of the fulltext search view you want to rename.
const newSearchViewName = "NewSearchView"; // Replace with the new name for the fulltext search view.
async function renameMySearchView () {
const listOfViews = await client.getListOfViews();
const view = listOfViews.result.find(v => v.name === searchViewName);
if (!view) {
console.log(`Search view "${searchViewName}" does not exist`);
return;
}
const renamedView = await client.renameView(view.name, newSearchViewName);
console.log(`Successfully renamed search view: ${renamedView.result.name}`);
}
renameMySearchView();