Skip to content

Latest commit

 

History

History
executable file
·
593 lines (476 loc) · 21.3 KB

IndexApi.md

File metadata and controls

executable file
·
593 lines (476 loc) · 21.3 KB

ManticoreSearch.Api.IndexApi

All URIs are relative to http://127.0.0.1:9308

Method HTTP request Description
Bulk POST /bulk Bulk table operations
Delete POST /delete Delete a document in a table
Insert POST /insert Create a new document in a table
PartialReplace POST /{table}/_update/{id} Partially replaces a document in a table
Replace POST /replace Replace new document in a table
Update POST /update Update a document in a table

Bulk

BulkResponse Bulk (string body)

Bulk table operations

Sends multiple operatons like inserts, updates, replaces or deletes. For each operation it's object must have same format as in their dedicated method. The method expects a raw string as the batch in NDJSON. Each operation object needs to be serialized to JSON and separated by endline (\n). An example of raw input: {\"insert\": {\"table\": \"movies\", \"doc\": {\"plot\": \"A secret team goes to North Pole\", \"rating\": 9.5, \"language\": [2, 3], \"title\": \"This is an older movie\", \"lon\": 51.99, \"meta\": {\"keywords\":[\"travel\",\"ice\"],\"genre\":[\"adventure\"]}, \"year\": 1950, \"lat\": 60.4, \"advise\": \"PG-13\"}}} \\n {\"delete\": {\"table\": \"movies\",\"id\":700}} Responds with an object telling whenever any errors occured and an array with status for each operation: { 'items': [ { 'update':{'table':'products','id':1,'result':'updated'} }, { 'update':{'table':'products','id':2,'result':'updated'} } ], 'errors':false }

Example

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using ManticoreSearch.Api;
using ManticoreSearch.Client;
using ManticoreSearch.Model;

namespace Example
{
    public class BulkExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://127.0.0.1:9308";
            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new IndexApi(httpClient, config, httpClientHandler);
            var body = "body_example";  // string | 

            try
            {
                // Bulk table operations
                BulkResponse result = apiInstance.Bulk(body);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling IndexApi.Bulk: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the BulkWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Bulk table operations
    ApiResponse<BulkResponse> response = apiInstance.BulkWithHttpInfo(body);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling IndexApi.BulkWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
body string

Return type

BulkResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/x-ndjson
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 item updated -
0 error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Delete

DeleteResponse Delete (DeleteDocumentRequest deleteDocumentRequest)

Delete a document in a table

Delete one or several documents. The method has 2 ways of deleting: either by id, in case only one document is deleted or by using a match query, in which case multiple documents can be delete . Example of input to delete by id: {'table':'movies','id':100} Example of input to delete using a query: { 'table':'movies', 'query': { 'bool': { 'must': [ {'query_string':'new movie'} ] } } } The match query has same syntax as in for searching. Responds with an object telling how many documents got deleted: {'table':'products','updated':1}

Example

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using ManticoreSearch.Api;
using ManticoreSearch.Client;
using ManticoreSearch.Model;

namespace Example
{
    public class DeleteExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://127.0.0.1:9308";
            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new IndexApi(httpClient, config, httpClientHandler);
            var deleteDocumentRequest = new DeleteDocumentRequest(); // DeleteDocumentRequest | 

            try
            {
                // Delete a document in a table
                DeleteResponse result = apiInstance.Delete(deleteDocumentRequest);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling IndexApi.Delete: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the DeleteWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Delete a document in a table
    ApiResponse<DeleteResponse> response = apiInstance.DeleteWithHttpInfo(deleteDocumentRequest);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling IndexApi.DeleteWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
deleteDocumentRequest DeleteDocumentRequest

Return type

DeleteResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 item updated -
0 error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Insert

SuccessResponse Insert (InsertDocumentRequest insertDocumentRequest)

Create a new document in a table

Insert a document. Expects an object like: { 'table':'movies', 'id':701, 'doc': { 'title':'This is an old movie', 'plot':'A secret team goes to North Pole', 'year':1950, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'{\"keywords\":{\"travel\",\"ice\"},\"genre\":{\"adventure\"}}', 'language':[2,3] } } The document id can also be missing, in which case an autogenerated one will be used: { 'table':'movies', 'doc': { 'title':'This is a new movie', 'plot':'A secret team goes to North Pole', 'year':2020, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'{\"keywords\":{\"travel\",\"ice\"},\"genre\":{\"adventure\"}}', 'language':[2,3] } } It responds with an object in format: {'table':'products','id':701,'created':true,'result':'created','status':201}

Example

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using ManticoreSearch.Api;
using ManticoreSearch.Client;
using ManticoreSearch.Model;

namespace Example
{
    public class InsertExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://127.0.0.1:9308";
            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new IndexApi(httpClient, config, httpClientHandler);
            var insertDocumentRequest = new InsertDocumentRequest(); // InsertDocumentRequest | 

            try
            {
                // Create a new document in a table
                SuccessResponse result = apiInstance.Insert(insertDocumentRequest);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling IndexApi.Insert: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the InsertWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Create a new document in a table
    ApiResponse<SuccessResponse> response = apiInstance.InsertWithHttpInfo(insertDocumentRequest);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling IndexApi.InsertWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
insertDocumentRequest InsertDocumentRequest

Return type

SuccessResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
0 error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

PartialReplace

UpdateResponse PartialReplace (string table, long id, ReplaceDocumentRequest replaceDocumentRequest)

Partially replaces a document in a table

Partially replaces a document with given id in a table Responds with an object of the following format: {'table':'products','updated':1}

Example

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using ManticoreSearch.Api;
using ManticoreSearch.Client;
using ManticoreSearch.Model;

namespace Example
{
    public class PartialReplaceExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://127.0.0.1:9308";
            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new IndexApi(httpClient, config, httpClientHandler);
            var table = "table_example";  // string | Name of the percolate table
            var id = 789L;  // long | Id of the document to replace
            var replaceDocumentRequest = new ReplaceDocumentRequest(); // ReplaceDocumentRequest | 

            try
            {
                // Partially replaces a document in a table
                UpdateResponse result = apiInstance.PartialReplace(table, id, replaceDocumentRequest);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling IndexApi.PartialReplace: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the PartialReplaceWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Partially replaces a document in a table
    ApiResponse<UpdateResponse> response = apiInstance.PartialReplaceWithHttpInfo(table, id, replaceDocumentRequest);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling IndexApi.PartialReplaceWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
table string Name of the percolate table
id long Id of the document to replace
replaceDocumentRequest ReplaceDocumentRequest

Return type

UpdateResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 item updated -
0 error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Replace

SuccessResponse Replace (InsertDocumentRequest insertDocumentRequest)

Replace new document in a table

Replace an existing document. Input has same format as insert operation. Responds with an object in format: {'table':'products','id':1,'created':false,'result':'updated','status':200}

Example

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using ManticoreSearch.Api;
using ManticoreSearch.Client;
using ManticoreSearch.Model;

namespace Example
{
    public class ReplaceExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://127.0.0.1:9308";
            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new IndexApi(httpClient, config, httpClientHandler);
            var insertDocumentRequest = new InsertDocumentRequest(); // InsertDocumentRequest | 

            try
            {
                // Replace new document in a table
                SuccessResponse result = apiInstance.Replace(insertDocumentRequest);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling IndexApi.Replace: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the ReplaceWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Replace new document in a table
    ApiResponse<SuccessResponse> response = apiInstance.ReplaceWithHttpInfo(insertDocumentRequest);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling IndexApi.ReplaceWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
insertDocumentRequest InsertDocumentRequest

Return type

SuccessResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
0 error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Update

UpdateResponse Update (UpdateDocumentRequest updateDocumentRequest)

Update a document in a table

Update one or several documents. The update can be made by passing the id or by using a match query in case multiple documents can be updated. For example update a document using document id: {'table':'movies','doc':{'rating':9.49},'id':100} And update by using a match query: { 'table':'movies', 'doc':{'rating':9.49}, 'query': { 'bool': { 'must': [ {'query_string':'new movie'} ] } } } The match query has same syntax as for searching. Responds with an object that tells how many documents where updated in format: {'table':'products','updated':1}

Example

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using ManticoreSearch.Api;
using ManticoreSearch.Client;
using ManticoreSearch.Model;

namespace Example
{
    public class UpdateExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://127.0.0.1:9308";
            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new IndexApi(httpClient, config, httpClientHandler);
            var updateDocumentRequest = new UpdateDocumentRequest(); // UpdateDocumentRequest | 

            try
            {
                // Update a document in a table
                UpdateResponse result = apiInstance.Update(updateDocumentRequest);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling IndexApi.Update: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the UpdateWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Update a document in a table
    ApiResponse<UpdateResponse> response = apiInstance.UpdateWithHttpInfo(updateDocumentRequest);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling IndexApi.UpdateWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
updateDocumentRequest UpdateDocumentRequest

Return type

UpdateResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 item updated -
0 error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]