Schema API

This API is deprecated, please refer to the new RESTFul API instead.

http://{server_name}:9090/schema

The Schema API performs actions such as:

  • createindex: Creates a index.
  • deleteindex: Deletes a index.
  • indexlist: Lists all available indexes.
  • setfield: Sets a schema field for an index.
  • deletefield: Deletes a schema field in an index.

Global parameters:

  • use (required): The name of the index.
  • login (optional): The login parameter. This becomes required once you create a user.
  • key (optional): The key parameter related to the login (api key). This becomes required once you create a user.
  • cmd (required): The command to perform - create index, delete index, list index, delete field, set field.

Parameters for index creation:

  • index.name (required): The name of the index to be created.
  • index.template (required): The crawler template that will be used to create the OpenSearchServer instance. OpenSearchServer has three templates:
  • EMPTY_INDEX: This is an empty index. If you use this setting you will have to set a schema manually.
  • WEB_CRAWLER: This is an index with predefined fields, analysers and parsers. This template is suited to web crawling and indexation.
  • FILE_CRAWLER: This is an index with predefined fields, analysers and parsers. This template is suited to parsing and indexing files in file systems (.doc, .pdf, etc.).

Parameters for index deletion:

  • index.name (required): The name of the index to be deleted.

Parameters for field creation/update:

  • field.default (optional): This denotes whether the given field is set to default. The field.default parameter can be "YES" or "NO".
  • field.unique (optional): This denotes whether the field is set to unique. The field.unique parameter can be "YES" or "NO".
  • field.name (required): The name of the field to be created or set as a default field or an unique field.
  • field.analyzer (optional): The name of the analyzer.
  • field.stored (optional): This indicates whether the field needs to be stored. It has two options, "YES" and "NO".
  • field.indexed (optional): This indicates whether the field needs to be indexed. It has two options, "YES" and "NO".
  • field.termVector (optional): This indicates whether the term vector needs to be saved. It has three options - "YES", "NO" and POSITIONS_OFFSETS.

Parameters for field deletion:

  • field.name (required): The name of the field to be deleted.

Examples

HTTP request:

Creating an index:

http://localhost:9090/schema?cmd=createindex&index.name=index1&index.template=WEB_CRAWLER

 
Listing all available indexes:

http://localhost:9090/schema?cmd=indexlist

 
Deleting an index:

http://localhost:9090/schema?cmd=deleteindex&index.name=index1&index.delete.name=index1

 
Setting/creating a schema field:

http://localhost:9090/schema?cmd=setField&field.name=titleNew&field.analyzer=StandardAnalyzer&use=index1&field.stored=YES&field.indexed=YES&term.termVector=NO

HTTP response:

Response for deleting an index:

<response>
<entry key="Info">Index deleted: index</entry>
<entry key="Status">OK</entry>
</response>

Response for creating a new schema field:

<response>
<entry key="Info">field 'titleNew' added/updated</entry>
<entry key="Status">OK</entry>
</response>

Using PHP:

$ossAPI = new OssApi('http://localhost:9090');
$ossAPI->createIndex('index1');
  
$ossAPI = new OssApi('http://localhost:9090',index1);
$ossAPI->setField('id','','NO','YES','YES','','NO','YES');

View/edit on GitHub