manticoresearch

Version, currently 1.0.23 versions

github.com/Athsus/manticoresearch-crystal

No description declared in shard.yml.

0 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  manticoresearch:
    github: Athsus/manticoresearch-crystal
    version: ~> 1.0.2

Then run:

shards install

shard.yml

Crystal
>= 1.13.1
License
MIT
Author
Ao Yu
Targets
  • test from test.cr
  • utils_api_sql from examples/utils_api_sql.cr
  • index_api_bulk from examples/index_api_bulk.cr
  • utils_api_spec from spec/utils_api_spec.cr
  • index_api_delete from examples/index_api_delete.cr
  • index_api_insert from examples/index_api_insert.cr
  • index_api_update from examples/index_api_update.cr
  • index_api_replace from examples/index_api_replace.cr
  • search_api_search from examples/search_api_search.cr
  • search_api_percolate from examples/search_api_percolate.cr

Dependencies

This version declares no dependencies.

README

Manticore Crystal Client

Client for Manticore Search.

Installation & Usage

Install with Shards

TODO: installation not tested

To add the manticoresearch package to your Crystal project, add the following to your shard.yml:

dependencies:
  manticoresearch:
    github: Athsus/manticoresearch-crystal
    version: ~> 1.0.0

Then run shards install to install dependencies

Example Usage

require "manticoresearch"

# Define the Manticore Search configuration
config = Manticoresearch::Configuration.new("http://127.0.0.1:9308")

# Initialize the API client
api_client = Manticoresearch::ApiClient.new(config)

# Create an instance of the Index API
index_api = Manticoresearch::IndexApi.new(api_client)

# Perform a bulk insert
body = <<-NDJSON
{"insert": {"index": "test", "id": 1, "doc": {"title": "Title 1"}}}
{"insert": {"index": "test", "id": 2, "doc": {"title": "Title 2"}}}
NDJSON

begin
  # Bulk index operation
  response = index_api.bulk(body)
  puts response
rescue ex : Exception
  puts "Error: #{ex.message}"
end

# Search example
search_api = Manticoresearch::SearchApi.new(api_client)
search_request = {
  "index" => "test",
  "query" => { "match" => { "title" => "Title 1" } }
}

begin
  # Perform a search
  search_response = search_api.search(search_request)
  puts search_response
rescue ex : Exception
  puts "Error: #{ex.message}"
end

API Documentation

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

API Endpoints

ClassMethodHTTP requestDescription
IndexApibulkPOST /bulkBulk index operations
IndexApideletePOST /deleteDelete a document in an index
IndexApiinsertPOST /insertCreate a new document in an index
IndexApireplacePOST /replaceReplace a document in an index
IndexApiupdatePOST /updateUpdate a document in an index
SearchApipercolatePOST /pq/{index}/searchPerform reverse search on a percolate index
SearchApisearchPOST /searchPerforms a search on an index
UtilsApisqlPOST /sqlPerform SQL queries

For full API reference, please refer to the Manticore Search Documentation.

Author