Index API

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


API Update is the interface for inserting/updating documents in an OpenSearchServer search engine index.


  • 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.

Posting a XML file

One easy way to populate data is to upload a XML file using a post or a put http request, then to post this file using a post or a put http request.
In this example we'll use CURL:

curl -o log.out -H "Content-type: text/xml; charset=utf-8" -T documents.xml "http://localhost:9090/update?use=indexName"

And here is the XML format:

<?xml version="1.0" encoding="UTF-8"?>
  <document lang="en">
    <field name="id"><value>1</value></field>
    <field name="title"><value>Open Search Server</value></field>
    <field name="url"><value></value></field>
    <field name="user">
  <document lang="en">
    <field name="id"><value>2</value></field>
    <field name="title"><value>SaaS services | OpenSearchServer</value></field>
    <field name="url"><value></value></field>
    <field name="user">

Using PHP

The request is done using the PHP5 method OssApi::update. This class can be downloaded along with the OpenSearchServer source code, under the name oss_api.class.php.


The following creates an instance of the OSS_IndexDocument class. This object can carry one or more documents to index.

$index = new OssIndexDocument();

The following adds a document:

$document = $index->newDocument('en');

The following adds a field within the document:

$document->newField('id', '1234');
$document->newField('title', 'Open Search Server');
$document->newField('content', 'Open Source Search Engine');
$document->newField('meta', 'Open Source');
$document->newField('meta', 'Search Engine'); // Multi value field

The following inserts the document(s) within the index:

$server = new OssApi('http://localhost:9090', 'indexName');

View/edit on GitHub

comments powered by Disqus