Dev tools GUI

更新时间:
复制 MD 格式

Lindorm Search Engine provides a graphical user interface (GUI), which you can use to send RESTful API requests to access Lindorm Search Engine. This topic describes how to use the Lindorm console to log in to the UI and execute read and write requests.

Prerequisites

  • The service type of your instance is Lindorm V1 or Lindorm. To learn how to view the service type, see View the product series.

  • LindormSearch is activated. For more information, see Activation guide.

  • Your client's IP address is in the Lindorm whitelist. For more information, see Configure a whitelist.

    Important

    If your client uses IPv6 by default, disable it. Otherwise, the whitelist verification fails.

Procedure

Log on to the GUI

  1. Log on to the Lindorm console.

  2. In the upper-left corner of the page, select the region where your instance is located.

  3. On the Instances page, click the ID of the target instance or click View Instance Details in the Actions column.

  4. In the left-side navigation pane, click Search Engine.

  5. In the UI Access section, click Internet or VPC to log on to the cluster management system.

  6. On the logon page, enter the Default Username and Default Initial Password that are displayed in the UI Access section.

    Note
    • The first time you access the UI, it may take a few moments for the page resources to load.

    • For your first login, you must use the Default Username and Default Initial Password to log in to the Search UI. For subsequent logins, you can use other users created by the default user to log in to the Cluster Management UI. For more information about user management, see User and Permission Management.

Read and write operations

Important

The syntax for read and write operations is compatible with Elasticsearch (ES) API 7.x.

Dev tools

  1. Click the image icon in the upper-left corner to open the sidebar, and then click Management > Dev Tools.

  2. In Dev Tools, you can send RESTful API requests to LindormSearch.

View all created indexes

Use the cat API to view basic information about all indexes in LindormSearch.

Add the v parameter to the request path to display the column headers in the response.

GET /_cat/indices?v

The following response is returned:

health status index     uuid      pri rep docs.count docs.deleted store.size pri.store.size
green  open   test2     test2       2   0          0            0       416b           416b
green  open   test3     test3       2   0          1            0     16.8kb         16.8kb
green  open   test1     test1       1   0          0            0       208b           208b
green  open   .kibana_1 .kibana_1   1   0          1            0      5.1kb          5.1kb

Create an index

Use the Create index API to add a new index.

In the request body, you can specify the settings and mappings for the index.

  • settings: The configuration of the index. For example, you can specify the number of shards (index.number_of_shards) and the refresh interval (index.refresh_interval), which is the maximum time from when a document is indexed until it becomes searchable.

  • mappings: The schema of the index. For example, you can define the fields and their data types.

    PUT /test
    {
      "settings": {
        "index.number_of_shards": 2,
        "index.refresh_interval": "10s"
      },
      "mappings": {
        "properties": {
          "firstName": {
            "type": "keyword"
          },
          "lastName": {
            "type": "keyword"
          }
        }
      }
    }

    The following response is returned:

    {
      "acknowledged": true,
      "shards_acknowledged": true,
      "index": "test"
    }

View a specific index

  • Use the Get index API to view an index's settings and mappings.

    GET /test

    The following response is returned:

    {
      "test": {
        "aliases": {},
        "mappings": {
          "properties": {
            "firstName": {
              "type": "keyword"
            },
            "lastName": {
              "type": "keyword"
            }
          }
        },
        "settings": {
          "index": {
            "search": {
              "slowlog": {
                "level": "DEBUG",
                "threshold": {
                  "fetch": {
                    "warn": "1s",
                    "trace": "200ms",
                    "debug": "500ms",
                    "info": "800ms"
                  },
                  "query": {
                    "warn": "10s",
                    "trace": "500ms",
                    "debug": "1s",
                    "info": "5s"
                  }
                }
              }
            },
            "refresh_interval": "10s",
            "indexing": {
              "slowlog": {
                "level": "DEBUG",
                "threshold": {
                  "index": {
                    "warn": "10s",
                    "trace": "500ms",
                    "debug": "2s",
                    "info": "5s"
                  }
                }
              }
            },
            "number_of_shards": "2",
            "provided_name": "test4",
            "creation_date": "1722418296110",
            "number_of_replicas": "0",
            "uuid": "test4",
            "version": {
              "created": "136287927"
            }
          }
        }
      }
    }
  • To view only the settings or mappings, you can use the Get index settings API or the Get mapping API.

    The following example shows how to retrieve the settings of an index.

    GET /test/_settings

    The following response is returned:

    {
      "test": {
        "settings": {
          "index": {
            "search": {
              "slowlog": {
                "level": "DEBUG",
                "threshold": {
                  "fetch": {
                    "warn": "1s",
                    "trace": "200ms",
                    "debug": "500ms",
                    "info": "800ms"
                  },
                  "query": {
                    "warn": "10s",
                    "trace": "500ms",
                    "debug": "1s",
                    "info": "5s"
                  }
                }
              }
            },
            "refresh_interval": "10s",
            "indexing": {
              "slowlog": {
                "level": "DEBUG",
                "threshold": {
                  "index": {
                    "warn": "10s",
                    "trace": "500ms",
                    "debug": "2s",
                    "info": "5s"
                  }
                }
              }
            },
            "number_of_shards": "2",
            "provided_name": "test4",
            "creation_date": "1722418296110",
            "number_of_replicas": "0",
            "uuid": "test4",
            "version": {
              "created": "136287927"
            }
          }
        }
      }
    }

Update index settings

Use the Update index settings API to update an index's dynamic settings.

The following example shows how to change the index.refresh_interval setting to 1s. This changes the time from when a document is indexed until it becomes searchable to 1 second. The minimum interval is 1 second.

PUT /test/_settings
{
  "index": {
    "refresh_interval": "1s"
  }
}

The following response is returned:

{
  "acknowledged": true
}

Write data to an index

Use the Index API to add or update documents in an index.

  • When you use the PUT method, you must explicitly specify an id. If the specified id already exists in the index, the new document overwrites the existing one.

    The following example sets the id to 1:

    PUT /test/_doc/1
    {
      "firstName": "John",
      "lastName": "Smith"
    }

    The following response is returned:

    {
      "_index": "test",
      "_type": "_doc",
      "_id": "1",
      "_version": 1,
      "result": "created",
      "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
      },
      "_seq_no": 0,
      "_primary_term": 1
    }
  • When you use the POST method, you can omit the id. LindormSearch automatically generates an id for the document.

    POST /test/_doc
    {
      "firstName": "Frank",
      "lastName": "Brown"
    }

    The following response is returned:

    {
      "_index": "test",
      "_type": "_doc",
      "_id": "b_MsCJEB3g4To6JSOeF6",
      "_version": 1,
      "result": "created",
      "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
      },
      "_seq_no": 0,
      "_primary_term": 1
    }

    LindormSearch automatically generates the id b_MsCJEB3g4To6JSOeF6 for the document.

  • Use the Update API to update specific fields of an existing document. The document id must be included in the request path, and the request body must contain the doc object.

    The following example updates the firstName field to Lane for the document with the id 1:

    POST /test/_update/1
    {
      "doc": {
        "firstName": "Lane"
      }
    }

    The following response is returned:

    {
      "_index": "test",
      "_type": "_doc",
      "_id": "1",
      "_version": 2,
      "result": "updated",
      "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
      },
      "_seq_no": 1,
      "_primary_term": 1
    }

Query data in an index

  • Use the Search API to query data in an index by specifying the query criteria in the request body.

    The following example searches for documents where the lastName is Smith:

    GET /test/_search
    {
      "query": {
        "match": {
          "lastName": "Smith"
        }
      }
    }

    The following response is returned:

    {
      "took": 4,
      "timed_out": false,
      "_shards": {
        "total": 2,
        "successful": 2,
        "skipped": 0,
        "failed": 0
      },
      "hits": {
        "total": {
          "value": 1,
          "relation": "eq"
        },
        "max_score": 0.18232156,
        "hits": [
          {
            "_index": "test",
            "_id": "1",
            "_score": 0.18232156,
            "_source": {
              "firstName": "Lane",
              "lastName": "Smith"
            }
          }
        ]
      }
    }
  • Use the Get API to retrieve a document by its id.

    The following example retrieves the document with the id 1:

    GET /test/_doc/1

    The following response is returned:

    {
      "_index": "test",
      "_id": "1",
      "_version": 2,
      "_seq_no": 1,
      "_primary_term": 1,
      "found": true,
      "_source": {
        "firstName": "Lane",
        "lastName": "Smith"
      }
    }

Delete data from an index

The Delete API deletes a document from an index by its id.

The following example deletes the document with the id 1:

DELETE /test/_doc/1

The following response is returned:

{
  "_index": "test",
  "_type": "_doc",
  "_id": "1",
  "_version": 3,
  "result": "deleted",
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 2,
  "_primary_term": 1
}

In the response, "successful": 1 indicates that the document was deleted.