manticoresearch.SearchApi

October 23, 2025 ยท View on GitHub

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

MethodHTTP requestDescription
searchPOST /searchPerforms a search on a table.
percolatePOST /pq/{table}/searchPerform a reverse search on a percolate table
autocompletePOST /autocompletePerforms an autocomplete search on a table

SearchResponse search(search_request)

Performs a search on a table.

The method expects a SearchRequest object with the following mandatory properties:

  • the name of the table to search | string

For details, see the documentation on SearchRequest

The method returns an object with the following properties:

  • hits: an object with the following properties:
    • hits: an array of hit objects, where each hit object represents a matched document. Each hit object has the following properties:
      • _id: the ID of the matched document.
      • _score: the score of the matched document.
      • _source: the source data of the matched document.
    • total: the total number of hits found.
  • timed_out: a boolean indicating whether the query timed out.
  • took: the time taken to execute the search query.

In addition, if profiling is enabled, the response will include an additional array with profiling information attached.

Here is an example search response:

{
  'took':10,
  'timed_out':false,
  'hits':
  {
    'total':2,
    'hits':
    [
      {'_id':'1','_score':1,'_source':{'gid':11}},
      {'_id':'2','_score':1,'_source':{'gid':12}}
    ]
  }
}

For more information about the match query syntax and additional parameters that can be added to request and response, please check: https://manual.manticoresearch.com/Searching/Full_text_matching/Basic_usage#HTTP-JSON.

Example

import manticoresearch
from manticoresearch.api import search_api
from manticoresearch.model.search_request import SearchRequest
from manticoresearch.model.error_response import ErrorResponse
from manticoresearch.model.search_response import SearchResponse
from manticoresearch.model.query_filter import QueryFilter
from pprint import pprint

# Defining the host is optional and defaults to http://127.0.0.1:9308
# See configuration.py for a list of all supported configuration parameters.
configuration = manticoresearch.Configuration(
    host = "http://127.0.0.1:9308"
)


# Enter a context with an instance of the API client
with manticoresearch.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = search_api.SearchApi(api_client)

	# Create SearchRequest
	search_request = SearchRequest(table="test")
    search_query = SearchQuery(query_string="find smth")
    search_request.query = search_query 
    
    # or create SearchRequest in an alternative way as in the previous versions of the client, which uses a single complex JSON object 
    search_request = { "table": "test", "query": {"query_string": "find smth"} }
    
    # Both ways of creating SearchRequest are interchangeable and produce the same result  

    # example passing only required values which don't have defaults set
    try:
        # Performs a search
        api_response = api_instance.search(search_request)
        pprint(api_response)
    except manticoresearch.ApiException as e:
        print("Exception when calling SearchApi->search: %s\n" % e)


Parameters

NameTypeDescriptionNotes
search_requestSearchRequest

Return type

SearchResponse

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescription
200Success, query processed
500Server error

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

percolate

SearchResponse percolate(table,percolate_request)

Perform a reverse search on a percolate table. [More info on percolate tables in Manticore Search Manual]

This method must be used only on percolate tables.

Expects two parameters: the table name and an object with a document or an array of documents to search by. Here is an example of the object with a single document:

{
  "query":
  {
    "percolate":
    {
      "document":
      {
        "content":"sample content"
      }
    }
  }
}

Responds with an object with matched stored queries:

{
  'timed_out':false,
  'hits':
  {
    'total':2,
    'max_score':1,
    'hits':
    [
      {
        'table':'idx_pq_1',
        '_type':'doc',
        '_id':'2',
        '_score':'1',
        '_source':
        {
          'query':
          {
            'match':{'title':'some'}
          }
        }
      },
      {
        'table':'idx_pq_1',
        '_type':'doc',
        '_id':'5',
        '_score':'1',
        '_source':
        {
          'query':
          {
            'ql':'some | none'
          }
        }
      }
    ]
  }
}

And here is an example of the object with multiple documents:

{
  "query":
  {
    "percolate":
    {
      "documents": [
        {
          "content":"sample content"
        },
        {
          "content":"another sample content"
        }
      ]
    }
  }
}

Example

import manticoresearch
from manticoresearch.api import search_api
from manticoresearch.model.error_response import ErrorResponse
from manticoresearch.model.search_response import SearchResponse
from manticoresearch.model.percolate_request import PercolateRequest
from manticoresearch.model.percolate_request_query import PercolateRequestQuery
from pprint import pprint

# Defining the host is optional and defaults to http://127.0.0.1:9308
# See configuration.py for a list of all supported configuration parameters.
configuration = manticoresearch.Configuration(
    host = "http://127.0.0.1:9308"
)


# Enter a context with an instance of the API client
with manticoresearch.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = search_api.SearchApi(api_client)

    table = "table_example" # str  | Name of the percolate table
    percolate_query = { 
        "query": { 
            "percolate": { 
                "document":  {  
                    "content":"sample content" 
                } 
            } 
        } 
    }
    percolate_request = PercolateRequest(
        query=PercolateRequestQuery(percolate_query),
    ) # PercolateRequest  

    # example passing only required values which don't have defaults set
    try:
        # Perform reverse search on a percolate table
        api_response = api_instance.percolate(table, percolate_request)
        pprint(api_response)
    except manticoresearch.ApiException as e:
        print("Exception when calling SearchApi->percolate: %s\n" % e)

Parameters

NameTypeDescriptionNotes
tablestrName of the percolate table
percolate_requestPercolateRequest

Return type

SearchResponse

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescription
200Success, query processed
500Server error

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

autocomplete

List[object] autocomplete(autocomplete_request)

Performs an autocomplete search on a table

The method expects an object with the following mandatory properties: * the name of the table to search * the query string to autocomplete For details, see the documentation on Autocomplete An example: { \"table\":\"table_name\", \"query\":\"query_beginning\" } An example of the method's response: [ { \"total\": 3, \"error\": \"\", \"warning\": \"\", \"columns\": [ { \"query\": { \"type\": \"string\" } } ], \"data\": [ { \"query\": \"hello\" }, { \"query\": \"helio\" }, { \"query\": \"hell\" } ] } ] For more detailed information about the autocomplete queries, please refer to the documentation here.

Example

import manticoresearch
from manticoresearch.models.autocomplete_request import AutocompleteRequest
from manticoresearch.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://127.0.0.1:9308
# See configuration.py for a list of all supported configuration parameters.
configuration = manticoresearch.Configuration(
    host = "http://127.0.0.1:9308"
)


# Enter a context with an instance of the API client
with manticoresearch.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = manticoresearch.SearchApi(api_client)
    autocomplete_request = AutocompleteRequest(table="test",query="abc") 

    try:
        # Performs an autocomplete search on a table
        api_response = api_instance.autocomplete(autocomplete_request)
        print("The response of SearchApi->autocomplete:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling SearchApi->autocomplete: %s\n" % e)

Parameters

NameTypeDescriptionNotes
autocomplete_requestAutocompleteRequest

Return type

List[object]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Ok-
0error-

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