diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100755 index 0000000..8558590 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,23 @@ +name: Publishing + +on: + push: + branches: + - test + + +jobs: + test: + uses: ./.github/workflows/test.yml + publish: + name: Publish the client to the public registry + needs: test + runs-on: ubuntu-latest + env: + CRATES_IO: ${{ secrets.CRATES_IO }} + + steps: + - uses: actions/checkout@v4 + - run: | + echo "Publishing to crates.io" + cargo login $CRATES_IO diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100755 index 0000000..ac7ba1f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: tests + +on: [workflow_call] + +jobs: + test: + + name: unit tests + runs-on: ubuntu-latest + + services: + manticoresearch-manticore: + image: manticoresearch/manticore:dev + env: + EXTRA: 1 + ports: + - 9308:9308 + + strategy: + matrix: + BUILD_TARGET: [release] + outputs: + release_built: ${{ steps.set-output.outputs.release_built }} + steps: + - uses: actions/checkout@v4 + - name: Build binaries in "${{ matrix.BUILD_TARGET }}" mode + run: cargo build --profile ${{ matrix.BUILD_TARGET }} + - name: Run tests in "${{ matrix.BUILD_TARGET }}" mode + run: cargo test --profile ${{ matrix.BUILD_TARGET }} -- --show-output + diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..6aa1064 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore new file mode 100755 index 0000000..7484ee5 --- /dev/null +++ b/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES new file mode 100755 index 0000000..331d0a2 --- /dev/null +++ b/.openapi-generator/FILES @@ -0,0 +1,100 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/AggComposite.md +docs/AggCompositeSource.md +docs/AggCompositeTerm.md +docs/AggTerms.md +docs/Aggregation.md +docs/AutocompleteRequest.md +docs/BoolFilter.md +docs/BulkResponse.md +docs/DeleteDocumentRequest.md +docs/DeleteResponse.md +docs/ErrorResponse.md +docs/FulltextFilter.md +docs/GeoDistance.md +docs/GeoDistanceLocationAnchor.md +docs/Highlight.md +docs/HighlightFieldOption.md +docs/HitsHits.md +docs/IndexApi.md +docs/InsertDocumentRequest.md +docs/Join.md +docs/JoinCond.md +docs/JoinOn.md +docs/KnnQuery.md +docs/Match.md +docs/MatchAll.md +docs/PercolateRequest.md +docs/PercolateRequestQuery.md +docs/QueryFilter.md +docs/Range.md +docs/ReplaceDocumentRequest.md +docs/ResponseError.md +docs/ResponseErrorDetails.md +docs/SearchApi.md +docs/SearchQuery.md +docs/SearchRequest.md +docs/SearchResponse.md +docs/SearchResponseHits.md +docs/SourceRules.md +docs/SqlObjResponse.md +docs/SqlResponse.md +docs/SuccessResponse.md +docs/UpdateDocumentRequest.md +docs/UpdateResponse.md +docs/UtilsApi.md +git_push.sh +src/apis/client.rs +src/apis/configuration.rs +src/apis/index_api.rs +src/apis/mod.rs +src/apis/request.rs +src/apis/search_api.rs +src/apis/utils_api.rs +src/lib.rs +src/models/_match.rs +src/models/agg_composite.rs +src/models/agg_composite_source.rs +src/models/agg_composite_term.rs +src/models/agg_terms.rs +src/models/aggregation.rs +src/models/autocomplete_request.rs +src/models/bool_filter.rs +src/models/bulk_response.rs +src/models/delete_document_request.rs +src/models/delete_response.rs +src/models/error_response.rs +src/models/fulltext_filter.rs +src/models/geo_distance.rs +src/models/geo_distance_location_anchor.rs +src/models/highlight.rs +src/models/highlight_field_option.rs +src/models/hits_hits.rs +src/models/insert_document_request.rs +src/models/join.rs +src/models/join_cond.rs +src/models/join_on.rs +src/models/knn_query.rs +src/models/match_all.rs +src/models/mod.rs +src/models/percolate_request.rs +src/models/percolate_request_query.rs +src/models/query_filter.rs +src/models/range.rs +src/models/replace_document_request.rs +src/models/response_error.rs +src/models/response_error_details.rs +src/models/search_query.rs +src/models/search_request.rs +src/models/search_response.rs +src/models/search_response_hits.rs +src/models/source_rules.rs +src/models/sql_obj_response.rs +src/models/sql_response.rs +src/models/success_response.rs +src/models/update_document_request.rs +src/models/update_response.rs diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION new file mode 100755 index 0000000..fff4bdd --- /dev/null +++ b/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.3.0-SNAPSHOT \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..30f13c9 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + manticoresearch-rust + + + + + + + + diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 0000000..22761ba --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/Cargo.toml b/Cargo.toml new file mode 100755 index 0000000..53831ca --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "manticoresearch" +version = "1.0.0" +authors = ["info@manticoresearch.com"] +description = "Сlient for Manticore Search. " +license = "MIT" +edition = "2021" + +[dependencies] +tokio = {version = "1", features = ["full"]} +fancy-regex = "^0.14" +serde = { version = "^1.0", features = ["derive"] } +serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] } +serde_json = "^1.0" +serde_repr = "^0.1" +url = "^2.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } +http = "~0.2" +base64 = "~0.7.0" +futures = "^0.3" diff --git a/LICENSE b/LICENSE.txt old mode 100644 new mode 100755 similarity index 92% rename from LICENSE rename to LICENSE.txt index 5cf4d38..57189b7 --- a/LICENSE +++ b/LICENSE.txt @@ -1,6 +1,6 @@ -MIT License +The MIT License (MIT) -Copyright (c) 2025 Manticore Search +Copyright (c) 2020-2025, Manticore Software LTD Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 416dd7c..f7463bf --- a/README.md +++ b/README.md @@ -1,4 +1,190 @@ -# manticoresearch-rust -Rust client for Manticore Search +# Manticore Rust client -Coming soon. +❗ WARNING: this is a development version of the client. The latest release's readme is https://github.com/manticoresoftware/manticoresearch-rust/tree/1.0.0 + + +Сlient for Manticore Search. + + +For more information, please visit [https://manticoresearch.com/contact-us/](https://manticoresearch.com/contact-us/) + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 5.0.0 +- Package version: 1.0.0 +- Generator version: 7.3.0-SNAPSHOT +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `manticoresearch` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +manticoresearch = { path = "./manticoresearch" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://127.0.0.1:9308* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*IndexApi* | [**bulk**](docs/IndexApi.md#bulk) | **Post** /bulk | Bulk table operations +*IndexApi* | [**delete**](docs/IndexApi.md#delete) | **Post** /delete | Delete a document in a table +*IndexApi* | [**insert**](docs/IndexApi.md#insert) | **Post** /insert | Create a new document in a table +*IndexApi* | [**partial_replace**](docs/IndexApi.md#partial_replace) | **Post** /{table}/_update/{id} | Partially replaces a document in a table +*IndexApi* | [**replace**](docs/IndexApi.md#replace) | **Post** /replace | Replace new document in a table +*IndexApi* | [**update**](docs/IndexApi.md#update) | **Post** /update | Update a document in a table +*SearchApi* | [**autocomplete**](docs/SearchApi.md#autocomplete) | **Post** /autocomplete | Performs an autocomplete search on a table +*SearchApi* | [**percolate**](docs/SearchApi.md#percolate) | **Post** /pq/{table}/search | Perform reverse search on a percolate table +*SearchApi* | [**search**](docs/SearchApi.md#search) | **Post** /search | Performs a search on a table +*UtilsApi* | [**sql**](docs/UtilsApi.md#sql) | **Post** /sql | Perform SQL requests + + +## Documentation For Models + + - [AggComposite](docs/AggComposite.md) + - [AggCompositeSource](docs/AggCompositeSource.md) + - [AggCompositeTerm](docs/AggCompositeTerm.md) + - [AggTerms](docs/AggTerms.md) + - [Aggregation](docs/Aggregation.md) + - [AutocompleteRequest](docs/AutocompleteRequest.md) + - [BoolFilter](docs/BoolFilter.md) + - [BulkResponse](docs/BulkResponse.md) + - [DeleteDocumentRequest](docs/DeleteDocumentRequest.md) + - [DeleteResponse](docs/DeleteResponse.md) + - [ErrorResponse](docs/ErrorResponse.md) + - [FulltextFilter](docs/FulltextFilter.md) + - [GeoDistance](docs/GeoDistance.md) + - [GeoDistanceLocationAnchor](docs/GeoDistanceLocationAnchor.md) + - [Highlight](docs/Highlight.md) + - [HighlightFieldOption](docs/HighlightFieldOption.md) + - [HitsHits](docs/HitsHits.md) + - [InsertDocumentRequest](docs/InsertDocumentRequest.md) + - [Join](docs/Join.md) + - [JoinCond](docs/JoinCond.md) + - [JoinOn](docs/JoinOn.md) + - [KnnQuery](docs/KnnQuery.md) + - [Match](docs/Match.md) + - [MatchAll](docs/MatchAll.md) + - [PercolateRequest](docs/PercolateRequest.md) + - [PercolateRequestQuery](docs/PercolateRequestQuery.md) + - [QueryFilter](docs/QueryFilter.md) + - [Range](docs/Range.md) + - [ReplaceDocumentRequest](docs/ReplaceDocumentRequest.md) + - [ResponseError](docs/ResponseError.md) + - [ResponseErrorDetails](docs/ResponseErrorDetails.md) + - [SearchQuery](docs/SearchQuery.md) + - [SearchRequest](docs/SearchRequest.md) + - [SearchResponse](docs/SearchResponse.md) + - [SearchResponseHits](docs/SearchResponseHits.md) + - [SourceRules](docs/SourceRules.md) + - [SqlObjResponse](docs/SqlObjResponse.md) + - [SqlResponse](docs/SqlResponse.md) + - [SuccessResponse](docs/SuccessResponse.md) + - [UpdateDocumentRequest](docs/UpdateDocumentRequest.md) + - [UpdateResponse](docs/UpdateResponse.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Compatibility table + +| **manticoresearch-rust* | **Manticore Search** | **Compatibility** | +| ------------------------| ----------------------------------- | ------------------------| +| `manticoresearch-dev` | `dev` (latest development version) | ✅ Fully Compatible | +| 1.0.0 or newer | 7.0.0 or newer | ✅ Fully Compatible | + + +## Getting started + +```rust + +use std::sync::Arc; +use std::collections::HashMap; +use serde_json; +use http_body_util::BodyExt; +use tokio; +use manticoresearch::{ + apis::{ + {Error,configuration::Configuration,IndexApi,IndexApiClient,SearchApi,SearchApiClient,UtilsApi,UtilsApiClient} + }, + models::{SearchRequest,SearchQuery,Highlight} +}; + + +#[tokio::main] +async fn main() { + let api_config = Arc::new(Configuration::new()); + let utils_api = UtilsApiClient::new(api_config.clone()); + let index_api = IndexApiClient::new(api_config.clone()); + let search_api = SearchApiClient::new(api_config.clone()); + + // Drop table if it exists + let _ = utils_api.sql("DROP TABLE IF EXISTS movies", Some(true)).await; + + // Create table + let _ = utils_api + .sql( + "CREATE TABLE IF NOT EXISTS movies (title text, plot text, _year integer, rating float, cat string, code multi, type_vector float_vector knn_type='hnsw' knn_dims='3' hnsw_similarity='l2')", + Some(true), + ) + .await; + + // Bulk insert documents + let bulk_body = r#"{"insert": {"table" : "movies", "id" : 1, "doc" : {"title" : "Star Trek 2: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2002, "rating": 6.4, "cat": "R", "code": [1,2,3], "type_vector": [0.2, 1.4, -2.3]}}} +{"insert": {"table" : "movies", "id" : 2, "doc" : {"title" : "Star Trek 1: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2001, "rating": 6.5, "cat": "PG-13", "code": [1,12,3], "type_vector": [0.8, 0.4, 1.3]}}} +{"insert": {"table" : "movies", "id" : 3, "doc" : {"title" : "Star Trek 3: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2003, "rating": 6.6, "cat": "R", "code": [11,2,3], "type_vector": [1.5, -1.0, 1.6]}}} +{"insert": {"table" : "movies", "id" : 4, "doc" : {"title" : "Star Trek 4: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2003, "rating": 6.0, "cat": "R", "code": [1,2,4], "type_vector": [0.4, 2.4, 0.9]}}} +"#; + + let _ = index_api.bulk(bulk_body).await; + + // Prepare search request + let query = SearchQuery { + query_string: Some(serde_json::json!("Star").into()), + ..Default::default() + }; + + let highlight = Highlight { + fields: Some(serde_json::json!(["title"]).into()), + ..Default::default() + }; + + let mut options = HashMap::new(); + options.insert("cutoff".to_string(), serde_json::json!(5)); + options.insert("ranker".to_string(), serde_json::json!("bm25")); + + let search_request = SearchRequest { + table: "movies".to_string(), + query: Some(Box::new(query)), + highlight: Some(Box::new(highlight)), + options: Some(serde_json::json!(options)), + ..Default::default() + }; + + // Perform search + let res = search_api.search(search_request).await; + + let _ = match res { + Ok(result) => { + println!("Search result: {:?}", result) + }, + Err(error) => { + if let Error::Api(error_info) = error { + let body_bytes = error_info.body.collect().await.expect("ERROR RESPONSE").to_bytes(); + println!("Error response: {:?}", String::from_utf8(body_bytes.to_vec()).unwrap()) + } + } + }; + +} + + +``` diff --git a/docs/AggComposite.md b/docs/AggComposite.md new file mode 100755 index 0000000..80e99ba --- /dev/null +++ b/docs/AggComposite.md @@ -0,0 +1,12 @@ +# AggComposite + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | Option<**i32**> | Maximum number of composite buckets in the result | [optional] +**sources** | Option<[**Vec<::std::collections::HashMap>**](map.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/AggCompositeSource.md b/docs/AggCompositeSource.md new file mode 100755 index 0000000..167d70b --- /dev/null +++ b/docs/AggCompositeSource.md @@ -0,0 +1,11 @@ +# AggCompositeSource + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**terms** | [**crate::models::AggCompositeTerm**](aggCompositeTerm.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/AggCompositeTerm.md b/docs/AggCompositeTerm.md new file mode 100755 index 0000000..61f5861 --- /dev/null +++ b/docs/AggCompositeTerm.md @@ -0,0 +1,11 @@ +# AggCompositeTerm + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**field** | **String** | Name of field to operate with | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/AggTerms.md b/docs/AggTerms.md new file mode 100755 index 0000000..600b706 --- /dev/null +++ b/docs/AggTerms.md @@ -0,0 +1,12 @@ +# AggTerms + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**field** | **String** | Name of attribute to aggregate by | +**size** | Option<**i32**> | Maximum number of buckets in the result | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Aggregation.md b/docs/Aggregation.md new file mode 100755 index 0000000..3c63441 --- /dev/null +++ b/docs/Aggregation.md @@ -0,0 +1,13 @@ +# Aggregation + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**terms** | Option<[**crate::models::AggTerms**](aggTerms.md)> | | [optional] +**sort** | Option<[**Vec**](serde_json::Value.md)> | | [optional] +**composite** | Option<[**crate::models::AggComposite**](aggComposite.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/AutocompleteRequest.md b/docs/AutocompleteRequest.md new file mode 100755 index 0000000..6e53f10 --- /dev/null +++ b/docs/AutocompleteRequest.md @@ -0,0 +1,13 @@ +# AutocompleteRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | **String** | The table to perform the search on | +**query** | **String** | The beginning of the string to autocomplete | +**options** | Option<[**serde_json::Value**](.md)> | Autocomplete options - layouts: A comma-separated string of keyboard layout codes to validate and check for spell correction. Available options - us, ru, ua, se, pt, no, it, gr, uk, fr, es, dk, de, ch, br, bg, be. By default, all are enabled. - fuzziness: (0,1 or 2) Maximum Levenshtein distance for finding typos. Set to 0 to disable fuzzy matching. Default is 2 - prepend: true/false If true, adds an asterisk before the last word for prefix expansion (e.g., *word ) - append: true/false If true, adds an asterisk after the last word for prefix expansion (e.g., word* ) - expansion_len: Number of characters to expand in the last word. Default is 10. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/BoolFilter.md b/docs/BoolFilter.md new file mode 100755 index 0000000..766d810 --- /dev/null +++ b/docs/BoolFilter.md @@ -0,0 +1,13 @@ +# BoolFilter + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**must** | Option<[**Vec**](queryFilter.md)> | Query clauses that must match for the document to be included | [optional] +**must_not** | Option<[**Vec**](queryFilter.md)> | Query clauses that must not match for the document to be included | [optional] +**should** | Option<[**Vec**](queryFilter.md)> | Query clauses that should be matched, but are not required | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/BulkResponse.md b/docs/BulkResponse.md new file mode 100755 index 0000000..319ac7f --- /dev/null +++ b/docs/BulkResponse.md @@ -0,0 +1,15 @@ +# BulkResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | Option<[**Vec**](serde_json::Value.md)> | List of results | [optional] +**errors** | Option<**bool**> | Errors occurred during the bulk operation | [optional] +**error** | Option<**String**> | Error message describing an error if such occurred | [optional] +**current_line** | Option<**i32**> | Number of the row returned in the response | [optional] +**skipped_lines** | Option<**i32**> | Number of rows skipped in the response | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/DeleteDocumentRequest.md b/docs/DeleteDocumentRequest.md new file mode 100755 index 0000000..6ddcf52 --- /dev/null +++ b/docs/DeleteDocumentRequest.md @@ -0,0 +1,14 @@ +# DeleteDocumentRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | **String** | Table name | +**cluster** | Option<**String**> | Cluster name | [optional] +**id** | Option<**i64**> | The ID of document for deletion | [optional] +**query** | Option<[**serde_json::Value**](.md)> | Defines the criteria to match documents for deletion | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/DeleteResponse.md b/docs/DeleteResponse.md new file mode 100755 index 0000000..d8c3512 --- /dev/null +++ b/docs/DeleteResponse.md @@ -0,0 +1,15 @@ +# DeleteResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | Option<**String**> | The name of the table from which the document was deleted | [optional] +**deleted** | Option<**i32**> | Number of documents deleted | [optional] +**id** | Option<**i64**> | The ID of the deleted document. If multiple documents are deleted, the ID of the first deleted document is returned | [optional] +**found** | Option<**bool**> | Indicates whether any documents to be deleted were found | [optional] +**result** | Option<**String**> | Result of the delete operation, typically 'deleted' | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ErrorResponse.md b/docs/ErrorResponse.md new file mode 100755 index 0000000..96e4b64 --- /dev/null +++ b/docs/ErrorResponse.md @@ -0,0 +1,12 @@ +# ErrorResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**error** | [**crate::models::ResponseError**](responseError.md) | | +**status** | Option<**i32**> | HTTP status code of the error response | [optional][default to 500] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/FulltextFilter.md b/docs/FulltextFilter.md new file mode 100755 index 0000000..98cee45 --- /dev/null +++ b/docs/FulltextFilter.md @@ -0,0 +1,14 @@ +# FulltextFilter + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**query_string** | Option<**String**> | Filter object defining a query string | [optional] +**r#match** | Option<[**serde_json::Value**](.md)> | Filter object defining a match keyword passed as a string or in a Match object | [optional] +**match_phrase** | Option<[**serde_json::Value**](.md)> | Filter object defining a match phrase | [optional] +**match_all** | Option<[**serde_json::Value**](.md)> | Filter object to select all documents | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/GeoDistance.md b/docs/GeoDistance.md new file mode 100755 index 0000000..c25a37a --- /dev/null +++ b/docs/GeoDistance.md @@ -0,0 +1,14 @@ +# GeoDistance + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**location_anchor** | Option<[**crate::models::GeoDistanceLocationAnchor**](geoDistance_location_anchor.md)> | | [optional] +**location_source** | Option<[**serde_json::Value**](.md)> | Field name in the document that contains location data | [optional] +**distance_type** | Option<[**serde_json::Value**](serde_json::Value.md)> | Algorithm used to calculate the distance | [optional] +**distance** | Option<[**serde_json::Value**](.md)> | The distance from the anchor point to filter results by | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/GeoDistanceLocationAnchor.md b/docs/GeoDistanceLocationAnchor.md new file mode 100755 index 0000000..1aa8dcc --- /dev/null +++ b/docs/GeoDistanceLocationAnchor.md @@ -0,0 +1,12 @@ +# GeoDistanceLocationAnchor + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**lat** | Option<[**serde_json::Value**](.md)> | Latitude of the anchor point | [optional] +**lon** | Option<[**serde_json::Value**](.md)> | Longitude of the anchor point | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Highlight.md b/docs/Highlight.md new file mode 100755 index 0000000..8b1d5d5 --- /dev/null +++ b/docs/Highlight.md @@ -0,0 +1,33 @@ +# Highlight + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**fragment_size** | Option<[**serde_json::Value**](.md)> | Maximum size of the text fragments in highlighted snippets per field | [optional] +**limit** | Option<[**serde_json::Value**](.md)> | Maximum size of snippets per field | [optional] +**limit_snippets** | Option<[**serde_json::Value**](.md)> | Maximum number of snippets per field | [optional] +**limit_words** | Option<[**serde_json::Value**](.md)> | Maximum number of words per field | [optional] +**number_of_fragments** | Option<[**serde_json::Value**](.md)> | Total number of highlighted fragments per field | [optional] +**after_match** | Option<**String**> | Text inserted after the matched term, typically used for HTML formatting | [optional][default to ] +**allow_empty** | Option<**bool**> | Permits an empty string to be returned as the highlighting result. Otherwise, the beginning of the original text would be returned | [optional] +**around** | Option<**i32**> | Number of words around the match to include in the highlight | [optional] +**before_match** | Option<**String**> | Text inserted before the match, typically used for HTML formatting | [optional][default to ] +**emit_zones** | Option<**bool**> | Emits an HTML tag with the enclosing zone name before each highlighted snippet | [optional] +**encoder** | Option<**String**> | If set to 'html', retains HTML markup when highlighting | [optional] +**fields** | Option<[**serde_json::Value**](.md)> | | [optional] +**force_all_words** | Option<**bool**> | Ignores the length limit until the result includes all keywords | [optional] +**force_snippets** | Option<**bool**> | Forces snippet generation even if limits allow highlighting the entire text | [optional] +**highlight_query** | Option<[**crate::models::QueryFilter**](queryFilter.md)> | | [optional] +**html_strip_mode** | Option<**String**> | Defines the mode for handling HTML markup in the highlight | [optional] +**limits_per_field** | Option<**bool**> | Determines whether the 'limit', 'limit_words', and 'limit_snippets' options operate as individual limits in each field of the document | [optional] +**no_match_size** | Option<**i32**> | If set to 1, allows an empty string to be returned as a highlighting result | [optional] +**order** | Option<**String**> | Sets the sorting order of highlighted snippets | [optional] +**pre_tags** | Option<**String**> | Text inserted before each highlighted snippet | [optional][default to ] +**post_tags** | Option<**String**> | Text inserted after each highlighted snippet | [optional][default to ] +**start_snippet_id** | Option<**i32**> | Sets the starting value of the %SNIPPET_ID% macro | [optional] +**use_boundaries** | Option<**bool**> | Defines whether to additionally break snippets by phrase boundary characters | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/HighlightFieldOption.md b/docs/HighlightFieldOption.md new file mode 100755 index 0000000..b2e37ef --- /dev/null +++ b/docs/HighlightFieldOption.md @@ -0,0 +1,15 @@ +# HighlightFieldOption + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**fragment_size** | Option<**i32**> | Maximum size of the text fragments in highlighted snippets per field | [optional] +**limit** | Option<**i32**> | Maximum size of snippets per field | [optional] +**limit_snippets** | Option<**i32**> | Maximum number of snippets per field | [optional] +**limit_words** | Option<**i32**> | Maximum number of words per field | [optional] +**number_of_fragments** | Option<**i32**> | Total number of highlighted fragments per field | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/HitsHits.md b/docs/HitsHits.md new file mode 100755 index 0000000..d933472 --- /dev/null +++ b/docs/HitsHits.md @@ -0,0 +1,18 @@ +# HitsHits + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | Option<**i64**> | The ID of the matched document | [optional] +**_score** | Option<**i32**> | The score of the matched document | [optional] +**_source** | Option<[**serde_json::Value**](.md)> | The source data of the matched document | [optional] +**_knn_dist** | Option<**f32**> | The knn distance of the matched document returned for knn queries | [optional] +**highlight** | Option<[**serde_json::Value**](.md)> | The highlighting-related data of the matched document | [optional] +**table** | Option<**String**> | The table name of the matched document returned for percolate queries | [optional] +**_type_colon** | Option<**String**> | The type of the matched document returned for percolate queries | [optional] +**fields** | Option<[**serde_json::Value**](.md)> | The percolate-related fields of the matched document returned for percolate queries | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/IndexApi.md b/docs/IndexApi.md new file mode 100755 index 0000000..91e51e7 --- /dev/null +++ b/docs/IndexApi.md @@ -0,0 +1,196 @@ +# \IndexApi + +All URIs are relative to *http://127.0.0.1:9308* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**bulk**](IndexApi.md#bulk) | **Post** /bulk | Bulk table operations +[**delete**](IndexApi.md#delete) | **Post** /delete | Delete a document in a table +[**insert**](IndexApi.md#insert) | **Post** /insert | Create a new document in a table +[**partial_replace**](IndexApi.md#partial_replace) | **Post** /{table}/_update/{id} | Partially replaces a document in a table +[**replace**](IndexApi.md#replace) | **Post** /replace | Replace new document in a table +[**update**](IndexApi.md#update) | **Post** /update | Update a document in a table + + + +## bulk + +> crate::models::BulkResponse bulk(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 } ``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | **String** | | [required] | + +### Return type + +[**crate::models::BulkResponse**](bulkResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/x-ndjson +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete + +> crate::models::DeleteResponse delete(delete_document_request) +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} ``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**delete_document_request** | [**DeleteDocumentRequest**](DeleteDocumentRequest.md) | | [required] | + +### Return type + +[**crate::models::DeleteResponse**](deleteResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## insert + +> crate::models::SuccessResponse insert(insert_document_request) +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} ``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**insert_document_request** | [**InsertDocumentRequest**](InsertDocumentRequest.md) | | [required] | + +### Return type + +[**crate::models::SuccessResponse**](successResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## partial_replace + +> crate::models::UpdateResponse partial_replace(table, id, replace_document_request) +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} ``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**table** | **String** | Name of the percolate table | [required] | +**id** | **i64** | Id of the document to replace | [required] | +**replace_document_request** | [**ReplaceDocumentRequest**](ReplaceDocumentRequest.md) | | [required] | + +### Return type + +[**crate::models::UpdateResponse**](updateResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## replace + +> crate::models::SuccessResponse replace(insert_document_request) +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} ``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**insert_document_request** | [**InsertDocumentRequest**](InsertDocumentRequest.md) | | [required] | + +### Return type + +[**crate::models::SuccessResponse**](successResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update + +> crate::models::UpdateResponse update(update_document_request) +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} ``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**update_document_request** | [**UpdateDocumentRequest**](UpdateDocumentRequest.md) | | [required] | + +### Return type + +[**crate::models::UpdateResponse**](updateResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/InsertDocumentRequest.md b/docs/InsertDocumentRequest.md new file mode 100755 index 0000000..df39864 --- /dev/null +++ b/docs/InsertDocumentRequest.md @@ -0,0 +1,14 @@ +# InsertDocumentRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | **String** | Name of the table to insert the document into | +**cluster** | Option<**String**> | Name of the cluster to insert the document into | [optional] +**id** | Option<**i64**> | Document ID. If not provided, an ID will be auto-generated | [optional] +**doc** | [**serde_json::Value**](.md) | Object containing document data | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Join.md b/docs/Join.md new file mode 100755 index 0000000..bf0a580 --- /dev/null +++ b/docs/Join.md @@ -0,0 +1,14 @@ +# Join + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | Type of the join operation | +**on** | [**Vec**](joinOn.md) | List of objects defining joined tables | +**query** | Option<[**crate::models::FulltextFilter**](fulltextFilter.md)> | | [optional] +**table** | **String** | Basic table of the join operation | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/JoinCond.md b/docs/JoinCond.md new file mode 100755 index 0000000..57d626d --- /dev/null +++ b/docs/JoinCond.md @@ -0,0 +1,13 @@ +# JoinCond + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**field** | **String** | Field to join on | +**table** | **String** | Joined table | +**r#type** | Option<[**serde_json::Value**](.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/JoinOn.md b/docs/JoinOn.md new file mode 100755 index 0000000..8b67264 --- /dev/null +++ b/docs/JoinOn.md @@ -0,0 +1,13 @@ +# JoinOn + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**right** | Option<[**crate::models::JoinCond**](joinCond.md)> | | [optional] +**left** | Option<[**crate::models::JoinCond**](joinCond.md)> | | [optional] +**operator** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/KnnQuery.md b/docs/KnnQuery.md new file mode 100755 index 0000000..39d887b --- /dev/null +++ b/docs/KnnQuery.md @@ -0,0 +1,16 @@ +# KnnQuery + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**field** | **String** | Field to perform the k-nearest neighbor search on | +**k** | **i32** | The number of nearest neighbors to return | +**query_vector** | Option<**Vec**> | The vector used as input for the KNN search | [optional] +**doc_id** | Option<**i64**> | The docuemnt ID used as input for the KNN search | [optional] +**ef** | Option<**i32**> | Optional parameter controlling the accuracy of the search | [optional] +**filter** | Option<[**crate::models::QueryFilter**](queryFilter.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Match.md b/docs/Match.md new file mode 100755 index 0000000..b9f8bc3 --- /dev/null +++ b/docs/Match.md @@ -0,0 +1,13 @@ +# Match + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**query** | **String** | | +**operator** | Option<**String**> | | [optional] +**boost** | Option<**f32**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/MatchAll.md b/docs/MatchAll.md new file mode 100755 index 0000000..877ea9e --- /dev/null +++ b/docs/MatchAll.md @@ -0,0 +1,11 @@ +# MatchAll + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_all** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/PercolateRequest.md b/docs/PercolateRequest.md new file mode 100755 index 0000000..4076d2c --- /dev/null +++ b/docs/PercolateRequest.md @@ -0,0 +1,11 @@ +# PercolateRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**query** | [**crate::models::PercolateRequestQuery**](percolateRequest_query.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/PercolateRequestQuery.md b/docs/PercolateRequestQuery.md new file mode 100755 index 0000000..e63d4bb --- /dev/null +++ b/docs/PercolateRequestQuery.md @@ -0,0 +1,11 @@ +# PercolateRequestQuery + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**percolate** | [**serde_json::Value**](.md) | Object representing the document to percolate | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/QueryFilter.md b/docs/QueryFilter.md new file mode 100755 index 0000000..9248d72 --- /dev/null +++ b/docs/QueryFilter.md @@ -0,0 +1,19 @@ +# QueryFilter + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**query_string** | Option<[**serde_json::Value**](.md)> | Filter object defining a query string | [optional] +**r#match** | Option<[**serde_json::Value**](.md)> | Filter object defining a match keyword passed as a string or in a Match object | [optional] +**match_phrase** | Option<[**serde_json::Value**](.md)> | Filter object defining a match phrase | [optional] +**match_all** | Option<[**serde_json::Value**](.md)> | Filter object to select all documents | [optional] +**bool** | Option<[**crate::models::BoolFilter**](boolFilter.md)> | | [optional] +**equals** | Option<[**serde_json::Value**](.md)> | | [optional] +**r#in** | Option<[**serde_json::Value**](.md)> | Filter to match a given set of attribute values. | [optional] +**range** | Option<[**serde_json::Value**](.md)> | Filter to match a given range of attribute values passed in Range objects | [optional] +**geo_distance** | Option<[**crate::models::GeoDistance**](geoDistance.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Range.md b/docs/Range.md new file mode 100755 index 0000000..ae70c4c --- /dev/null +++ b/docs/Range.md @@ -0,0 +1,14 @@ +# Range + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**lt** | Option<[**serde_json::Value**](.md)> | | [optional] +**lte** | Option<[**serde_json::Value**](.md)> | | [optional] +**gt** | Option<[**serde_json::Value**](.md)> | | [optional] +**gte** | Option<[**serde_json::Value**](.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ReplaceDocumentRequest.md b/docs/ReplaceDocumentRequest.md new file mode 100755 index 0000000..3fe0a66 --- /dev/null +++ b/docs/ReplaceDocumentRequest.md @@ -0,0 +1,11 @@ +# ReplaceDocumentRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**doc** | [**serde_json::Value**](.md) | Object containing the new document data to replace the existing one. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ResponseError.md b/docs/ResponseError.md new file mode 100755 index 0000000..785660a --- /dev/null +++ b/docs/ResponseError.md @@ -0,0 +1,12 @@ +# ResponseError + +## Enum Variants + +| Name | Description | +|---- | -----| +| ResponseErrorDetails | | +| String | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ResponseErrorDetails.md b/docs/ResponseErrorDetails.md new file mode 100755 index 0000000..25c290a --- /dev/null +++ b/docs/ResponseErrorDetails.md @@ -0,0 +1,13 @@ +# ResponseErrorDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | Type or category of the error | +**reason** | Option<**String**> | Detailed explanation of why the error occurred | [optional] +**table** | Option<**String**> | The table related to the error, if applicable | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SearchApi.md b/docs/SearchApi.md new file mode 100755 index 0000000..50ca0d5 --- /dev/null +++ b/docs/SearchApi.md @@ -0,0 +1,102 @@ +# \SearchApi + +All URIs are relative to *http://127.0.0.1:9308* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**autocomplete**](SearchApi.md#autocomplete) | **Post** /autocomplete | Performs an autocomplete search on a table +[**percolate**](SearchApi.md#percolate) | **Post** /pq/{table}/search | Perform reverse search on a percolate table +[**search**](SearchApi.md#search) | **Post** /search | Performs a search on a table + + + +## autocomplete + +> Vec 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**](Autocomplete.md) 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](https://manual.manticoresearch.com/Searching/Autocomplete). + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**autocomplete_request** | [**AutocompleteRequest**](AutocompleteRequest.md) | | [required] | + +### Return type + +[**Vec**](serde_json::Value.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## percolate + +> crate::models::SearchResponse percolate(table, percolate_request) +Perform reverse search on a percolate table + +Performs a percolate search. This method must be used only on percolate tables. Expects two parameters: the table name and an object with array of documents to be tested. An example of the documents object: ``` { \"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' } } } ] } } ``` + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**table** | **String** | Name of the percolate table | [required] | +**percolate_request** | [**PercolateRequest**](PercolateRequest.md) | | [required] | + +### Return type + +[**crate::models::SearchResponse**](searchResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## search + +> crate::models::SearchResponse search(search_request) +Performs a search on a table + + The method expects an object with the following mandatory properties: * the name of the table to search * the match query object For details, see the documentation on [**SearchRequest**](SearchRequest.md) The method returns an object with the following properties: - took: the time taken to execute the search query. - timed_out: a boolean indicating whether the query timed out. - hits: an object with the following properties: - total: the total number of hits found. - 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. In addition, if profiling is enabled, the response will include an additional array with profiling information attached. Also, if pagination is enabled, the response will include an additional 'scroll' property with a scroll token to use for pagination 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 see the documentation [here](https://manual.manticoresearch.com/Searching/Full_text_matching/Basic_usage#HTTP-JSON). + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**search_request** | [**SearchRequest**](SearchRequest.md) | | [required] | + +### Return type + +[**crate::models::SearchResponse**](searchResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/SearchQuery.md b/docs/SearchQuery.md new file mode 100755 index 0000000..8d9324d --- /dev/null +++ b/docs/SearchQuery.md @@ -0,0 +1,20 @@ +# SearchQuery + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**query_string** | Option<[**serde_json::Value**](.md)> | Filter object defining a query string | [optional] +**r#match** | Option<[**serde_json::Value**](.md)> | Filter object defining a match keyword passed as a string or in a Match object | [optional] +**match_phrase** | Option<[**serde_json::Value**](.md)> | Filter object defining a match phrase | [optional] +**match_all** | Option<[**serde_json::Value**](.md)> | Filter object to select all documents | [optional] +**bool** | Option<[**crate::models::BoolFilter**](boolFilter.md)> | | [optional] +**equals** | Option<[**serde_json::Value**](.md)> | | [optional] +**r#in** | Option<[**serde_json::Value**](.md)> | Filter to match a given set of attribute values. | [optional] +**range** | Option<[**serde_json::Value**](.md)> | Filter to match a given range of attribute values passed in Range objects | [optional] +**geo_distance** | Option<[**crate::models::GeoDistance**](geoDistance.md)> | | [optional] +**highlight** | Option<[**crate::models::Highlight**](highlight.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SearchRequest.md b/docs/SearchRequest.md new file mode 100755 index 0000000..f72a975 --- /dev/null +++ b/docs/SearchRequest.md @@ -0,0 +1,25 @@ +# SearchRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | **String** | The table to perform the search on | +**query** | Option<[**crate::models::SearchQuery**](searchQuery.md)> | | [optional] +**join** | Option<[**Vec**](join.md)> | Join clause to combine search data from multiple tables | [optional] +**highlight** | Option<[**crate::models::Highlight**](highlight.md)> | | [optional] +**limit** | Option<**i32**> | Maximum number of results to return | [optional] +**knn** | Option<[**crate::models::KnnQuery**](knnQuery.md)> | | [optional] +**aggs** | Option<[**::std::collections::HashMap**](aggregation.md)> | Defines aggregation settings for grouping results | [optional] +**expressions** | Option<**::std::collections::HashMap**> | Expressions to calculate additional values for the result | [optional] +**max_matches** | Option<**i32**> | Maximum number of matches allowed in the result | [optional] +**offset** | Option<**i32**> | Starting point for pagination of the result | [optional] +**options** | Option<[**serde_json::Value**](.md)> | Additional search options | [optional] +**profile** | Option<**bool**> | Enable or disable profiling of the search request | [optional] +**sort** | Option<[**serde_json::Value**](.md)> | | [optional] +**_source** | Option<[**serde_json::Value**](.md)> | | [optional] +**track_scores** | Option<**bool**> | Enable or disable result weight calculation used for sorting | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SearchResponse.md b/docs/SearchResponse.md new file mode 100755 index 0000000..ebbe0f1 --- /dev/null +++ b/docs/SearchResponse.md @@ -0,0 +1,17 @@ +# SearchResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**took** | Option<**i32**> | Time taken to execute the search | [optional] +**timed_out** | Option<**bool**> | Indicates whether the search operation timed out | [optional] +**aggregations** | Option<[**serde_json::Value**](.md)> | Aggregated search results grouped by the specified criteria | [optional] +**hits** | Option<[**crate::models::SearchResponseHits**](searchResponse_hits.md)> | | [optional] +**profile** | Option<[**serde_json::Value**](.md)> | Profile information about the search execution, if profiling is enabled | [optional] +**scroll** | Option<**String**> | Scroll token to be used fo pagination | [optional] +**warning** | Option<[**serde_json::Value**](.md)> | Warnings encountered during the search operation | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SearchResponseHits.md b/docs/SearchResponseHits.md new file mode 100755 index 0000000..59b2bea --- /dev/null +++ b/docs/SearchResponseHits.md @@ -0,0 +1,14 @@ +# SearchResponseHits + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**max_score** | Option<**i32**> | Maximum score among the matched documents | [optional] +**total** | Option<**i32**> | Total number of matched documents | [optional] +**total_relation** | Option<**String**> | Indicates whether the total number of hits is accurate or an estimate | [optional] +**hits** | Option<[**Vec**](hitsHits.md)> | Array of hit objects, each representing a matched document | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SourceRules.md b/docs/SourceRules.md new file mode 100755 index 0000000..3db4a13 --- /dev/null +++ b/docs/SourceRules.md @@ -0,0 +1,12 @@ +# SourceRules + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**includes** | Option<[**serde_json::Value**](.md)> | List of fields to include in the response | [optional][default to []] +**excludes** | Option<[**serde_json::Value**](.md)> | List of fields to exclude from the response | [optional][default to [""]] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SqlObjResponse.md b/docs/SqlObjResponse.md new file mode 100755 index 0000000..e6c40df --- /dev/null +++ b/docs/SqlObjResponse.md @@ -0,0 +1,11 @@ +# SqlObjResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**hits** | [**serde_json::Value**](.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SqlResponse.md b/docs/SqlResponse.md new file mode 100755 index 0000000..869fa39 --- /dev/null +++ b/docs/SqlResponse.md @@ -0,0 +1,12 @@ +# SqlResponse + +## Enum Variants + +| Name | Description | +|---- | -----| +| SqlObjResponse | List of responses from executed SQL queries | +| Vec | List of responses from executed SQL queries | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SuccessResponse.md b/docs/SuccessResponse.md new file mode 100755 index 0000000..d7988a5 --- /dev/null +++ b/docs/SuccessResponse.md @@ -0,0 +1,16 @@ +# SuccessResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | Option<**String**> | Name of the document table | [optional] +**id** | Option<**i64**> | ID of the document affected by the request operation | [optional] +**created** | Option<**bool**> | Indicates whether the document was created as a result of the operation | [optional] +**result** | Option<**String**> | Result of the operation, typically 'created', 'updated', or 'deleted' | [optional] +**found** | Option<**bool**> | Indicates whether the document was found in the table | [optional] +**status** | Option<**i32**> | HTTP status code representing the result of the operation | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/UpdateDocumentRequest.md b/docs/UpdateDocumentRequest.md new file mode 100755 index 0000000..87811b3 --- /dev/null +++ b/docs/UpdateDocumentRequest.md @@ -0,0 +1,15 @@ +# UpdateDocumentRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | **String** | Name of the document table | +**cluster** | Option<**String**> | Name of the document cluster | [optional] +**doc** | [**serde_json::Value**](.md) | Object containing the document fields to update | +**id** | Option<**i64**> | Document ID | [optional] +**query** | Option<[**crate::models::QueryFilter**](queryFilter.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/UpdateResponse.md b/docs/UpdateResponse.md new file mode 100755 index 0000000..1250c47 --- /dev/null +++ b/docs/UpdateResponse.md @@ -0,0 +1,14 @@ +# UpdateResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**table** | Option<**String**> | Name of the document table | [optional] +**updated** | Option<**i32**> | Number of documents updated | [optional] +**id** | Option<**i64**> | Document ID | [optional] +**result** | Option<**String**> | Result of the update operation, typically 'updated' | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/UtilsApi.md b/docs/UtilsApi.md new file mode 100755 index 0000000..5a5a7e5 --- /dev/null +++ b/docs/UtilsApi.md @@ -0,0 +1,40 @@ +# \UtilsApi + +All URIs are relative to *http://127.0.0.1:9308* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**sql**](UtilsApi.md#sql) | **Post** /sql | Perform SQL requests + + + +## sql + +> crate::models::SqlResponse sql(body, raw_response) +Perform SQL requests + +Run a query in SQL format. Expects a query string passed through `body` parameter and optional `raw_response` parameter that defines a format of response. `raw_response` can be set to `False` for Select queries only, e.g., `SELECT * FROM mytable` The query string must stay as it is, no URL encoding is needed. The response object depends on the query executed. In select mode the response has same format as `/search` operation. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**body** | **String** | A query parameter string. | [required] | +**raw_response** | Option<**bool**> | Optional parameter, defines a format of response. Can be set to `False` for Select only queries and set to `True` for any type of queries. Default value is 'True'. | |[default to true] + +### Return type + +[**crate::models::SqlResponse**](sqlResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: text/plain +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/git_push.sh b/git_push.sh new file mode 100755 index 0000000..22ef4ea --- /dev/null +++ b/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="manticoresoftware" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="manticoresearch-rust" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/src/apis/client.rs b/src/apis/client.rs new file mode 100755 index 0000000..831918b --- /dev/null +++ b/src/apis/client.rs @@ -0,0 +1,37 @@ +use std::sync::Arc; + +use hyper; +use hyper_util::client::legacy::connect::Connect; +use super::configuration::Configuration; + +pub struct APIClient { + index_api: Box, + search_api: Box, + utils_api: Box, +} + +impl APIClient { + pub fn new(configuration: Configuration) -> APIClient + where C: Clone + std::marker::Send + Sync + 'static { + let rc = Arc::new(configuration); + + APIClient { + index_api: Box::new(crate::apis::IndexApiClient::new(rc.clone())), + search_api: Box::new(crate::apis::SearchApiClient::new(rc.clone())), + utils_api: Box::new(crate::apis::UtilsApiClient::new(rc.clone())), + } + } + + pub fn index_api(&self) -> &dyn crate::apis::IndexApi{ + self.index_api.as_ref() + } + + pub fn search_api(&self) -> &dyn crate::apis::SearchApi{ + self.search_api.as_ref() + } + + pub fn utils_api(&self) -> &dyn crate::apis::UtilsApi{ + self.utils_api.as_ref() + } + +} diff --git a/src/apis/configuration.rs b/src/apis/configuration.rs new file mode 100755 index 0000000..5a571a9 --- /dev/null +++ b/src/apis/configuration.rs @@ -0,0 +1,69 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; + +pub struct Configuration + where C: Clone + std::marker::Send + Sync + 'static { + pub base_path: String, + pub user_agent: Option, + pub client: Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration + where C: Clone + std::marker::Send + Sync { + + /// Construct a new Configuration with a custom hyper client. + /// + pub fn with_client(client: Client) -> Configuration { + Configuration { + base_path: "http://127.0.0.1:9308".to_owned(), + user_agent: Some("OpenAPI-Generator/5.0.0/rust".to_owned()), + client, + basic_auth: None, + oauth_access_token: None, + api_key: None, + } + } +} + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} diff --git a/src/apis/index_api.rs b/src/apis/index_api.rs new file mode 100755 index 0000000..9086edf --- /dev/null +++ b/src/apis/index_api.rs @@ -0,0 +1,106 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use std::sync::Arc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use hyper_util::client::legacy::connect::Connect; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct IndexApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Arc>, +} + +impl IndexApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Arc>) -> IndexApiClient { + IndexApiClient { + configuration, + } + } +} + +pub trait IndexApi: Send + Sync { + fn bulk(&self, body: &str) -> Pin> + Send>>; + fn delete(&self, delete_document_request: models::DeleteDocumentRequest) -> Pin> + Send>>; + fn insert(&self, insert_document_request: models::InsertDocumentRequest) -> Pin> + Send>>; + fn partial_replace(&self, table: &str, id: i64, replace_document_request: models::ReplaceDocumentRequest) -> Pin> + Send>>; + fn replace(&self, insert_document_request: models::InsertDocumentRequest) -> Pin> + Send>>; + fn update(&self, update_document_request: models::UpdateDocumentRequest) -> Pin> + Send>>; +} + +implIndexApi for IndexApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn bulk(&self, body: &str) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/bulk".to_string()) + ; + req = req.with_body_param(body); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn delete(&self, delete_document_request: models::DeleteDocumentRequest) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/delete".to_string()) + ; + req = req.with_body_param(delete_document_request); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn insert(&self, insert_document_request: models::InsertDocumentRequest) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/insert".to_string()) + ; + req = req.with_body_param(insert_document_request); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn partial_replace(&self, table: &str, id: i64, replace_document_request: models::ReplaceDocumentRequest) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/{table}/_update/{id}".to_string()) + ; + req = req.with_path_param("table".to_string(), table.to_string()); + req = req.with_path_param("id".to_string(), id.to_string()); + req = req.with_body_param(replace_document_request); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn replace(&self, insert_document_request: models::InsertDocumentRequest) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/replace".to_string()) + ; + req = req.with_body_param(insert_document_request); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn update(&self, update_document_request: models::UpdateDocumentRequest) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/update".to_string()) + ; + req = req.with_body_param(update_document_request); + + req.execute(self.configuration.borrow()) + } + +} diff --git a/src/apis/mod.rs b/src/apis/mod.rs new file mode 100755 index 0000000..a099abb --- /dev/null +++ b/src/apis/mod.rs @@ -0,0 +1,77 @@ +use std::fmt; +use std::fmt::Debug; + +use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; +use serde_json; + +#[derive(Debug)] +pub enum Error { + Api(ApiError), + Header(http::header::InvalidHeaderValue), + Http(http::Error), + Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), + Serde(serde_json::Error), + UriError(http::uri::InvalidUri), +} + +pub struct ApiError { + pub code: hyper::StatusCode, + pub body: hyper::body::Incoming, +} + +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { + Error::Api(ApiError { + code: e.0, + body: e.1, + }) + } +} + +impl From for Error { + fn from(e: http::Error) -> Self { + Error::Http(e) + } +} + +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + +impl From for Error { + fn from(e: hyper::Error) -> Self { + Error::Hyper(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +mod request; + +mod index_api; +pub use self::index_api::{ IndexApi, IndexApiClient }; +mod search_api; +pub use self::search_api::{ SearchApi, SearchApiClient }; +mod utils_api; +pub use self::utils_api::{ UtilsApi, UtilsApiClient }; + +pub mod configuration; +pub mod client; diff --git a/src/apis/request.rs b/src/apis/request.rs new file mode 100755 index 0000000..faa57b8 --- /dev/null +++ b/src/apis/request.rs @@ -0,0 +1,264 @@ +use std::collections::HashMap; +use std::pin::Pin; + +use fancy_regex::Regex; +use futures; +use futures::Future; +use futures::future::*; +use http_body_util::BodyExt; +use hyper; +use hyper_util::client::legacy::connect::Connect; +use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; +use serde; +use serde_json; + +use super::{configuration, Error}; + +pub(crate) struct ApiKey { + pub in_header: bool, + pub in_query: bool, + pub param_name: String, +} + +impl ApiKey { + fn key(&self, prefix: &Option, key: &str) -> String { + match prefix { + None => key.to_owned(), + Some(ref prefix) => format!("{} {}", prefix, key), + } + } +} + +#[allow(dead_code)] +pub(crate) enum Auth { + None, + ApiKey(ApiKey), + Basic, + Oauth, +} + +/// If the authorization type is unspecified then it will be automatically detected based +/// on the configuration. This functionality is useful when the OpenAPI definition does not +/// include an authorization scheme. +pub(crate) struct Request { + auth: Option, + method: hyper::Method, + path: String, + query_params: HashMap, + no_return_type: bool, + path_params: HashMap, + form_params: HashMap, + header_params: HashMap, + // TODO: multiple body params are possible technically, but not supported here. + serialized_body: Option, +} + +#[allow(dead_code)] +impl Request { + pub fn new(method: hyper::Method, path: String) -> Self { + Request { + auth: None, + method, + path, + query_params: HashMap::new(), + path_params: HashMap::new(), + form_params: HashMap::new(), + header_params: HashMap::new(), + serialized_body: None, + no_return_type: false, + } + } + + pub fn with_body_param(mut self, param: T) -> Self { + self.serialized_body = Some(serde_json::to_string(¶m).unwrap()); + self + } + + pub fn with_header_param(mut self, basename: String, param: String) -> Self { + self.header_params.insert(basename, param); + self + } + + #[allow(unused)] + pub fn with_query_param(mut self, basename: String, param: String) -> Self { + self.query_params.insert(basename, param); + self + } + + #[allow(unused)] + pub fn with_path_param(mut self, basename: String, param: String) -> Self { + self.path_params.insert(basename, param); + self + } + + #[allow(unused)] + pub fn with_form_param(mut self, basename: String, param: String) -> Self { + self.form_params.insert(basename, param); + self + } + + pub fn returns_nothing(mut self) -> Self { + self.no_return_type = true; + self + } + + pub fn with_auth(mut self, auth: Auth) -> Self { + self.auth = Some(auth); + self + } + + pub fn execute<'a, C, U>( + self, + conf: &configuration::Configuration, + ) -> Pin> + 'a + Send>> + where + C: Connect + Clone + std::marker::Send + Sync, + U: Sized + std::marker::Send + 'a, + for<'de> U: serde::Deserialize<'de>, + { + let mut query_string = ::url::form_urlencoded::Serializer::new("".to_owned()); + + let mut path = self.path; + for (k, v) in self.path_params { + // replace {id} with the value of the id path param + path = path.replace(&format!("{{{}}}", k), &v); + } + + for (key, val) in self.query_params { + query_string.append_pair(&key, &val); + } + + let mut uri_str = format!("{}{}", conf.base_path, path); + + let query_string_str = query_string.finish(); + if !query_string_str.is_empty() { + uri_str += "?"; + uri_str += &query_string_str; + } + let uri: hyper::Uri = match uri_str.parse() { + Err(e) => return Box::pin(futures::future::err(Error::UriError(e))), + Ok(u) => u, + }; + + let mut req_builder = hyper::Request::builder() + .uri(uri) + .method(self.method); + + // Detect the authorization type if it hasn't been set. + let auth = self.auth.unwrap_or_else(|| + if conf.api_key.is_some() { + panic!("Cannot automatically set the API key from the configuration, it must be specified in the OpenAPI definition") + } else if conf.oauth_access_token.is_some() { + Auth::Oauth + } else if conf.basic_auth.is_some() { + Auth::Basic + } else { + Auth::None + } + ); + match auth { + Auth::ApiKey(apikey) => { + if let Some(ref key) = conf.api_key { + let val = apikey.key(&key.prefix, &key.key); + if apikey.in_query { + query_string.append_pair(&apikey.param_name, &val); + } + if apikey.in_header { + req_builder = req_builder.header(&apikey.param_name, val); + } + } + } + Auth::Basic => { + if let Some(ref auth_conf) = conf.basic_auth { + let mut text = auth_conf.0.clone(); + text.push(':'); + if let Some(ref pass) = auth_conf.1 { + text.push_str(&pass[..]); + } + let encoded = base64::encode(&text); + req_builder = req_builder.header(AUTHORIZATION, encoded); + } + } + Auth::Oauth => { + if let Some(ref token) = conf.oauth_access_token { + let text = "Bearer ".to_owned() + token; + req_builder = req_builder.header(AUTHORIZATION, text); + } + } + Auth::None => {} + } + + if let Some(ref user_agent) = conf.user_agent { + req_builder = req_builder.header(USER_AGENT, match HeaderValue::from_str(user_agent) { + Ok(header_value) => header_value, + Err(e) => return Box::pin(futures::future::err(super::Error::Header(e))) + }); + } + + for (k, v) in self.header_params { + req_builder = req_builder.header(&k, v); + } + + let req_headers = req_builder.headers_mut().unwrap(); + let request_result = if self.form_params.len() > 0 { + req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/x-www-form-urlencoded")); + let mut enc = ::url::form_urlencoded::Serializer::new("".to_owned()); + for (k, v) in self.form_params { + enc.append_pair(&k, &v); + } + req_builder.body(enc.finish()) + } else if let Some(body) = self.serialized_body { + let req_len; + let mut req_body; + let content_type; + if body[0..1] == "\"".to_string() { + req_len = body.len()-2; + req_body = body[1..body.len()-1].to_string(); + } else { + req_len = body.len(); + req_body = body.to_string(); + } + if path == "/bulk".to_string() { + content_type = HeaderValue::from_static("application/x-ndjson"); + let re = Regex::new(r#"(? request, + Err(e) => return Box::pin(futures::future::err(Error::from(e))) + }; + let no_return_type = self.no_return_type; + Box::pin(conf.client + .request(request) + .map_err(|e| Error::from(e)) + .and_then(move |response| { + let status = response.status(); + if !status.is_success() { + futures::future::err::(Error::from((status, response.into_body()))).boxed() + } else if no_return_type { + // This is a hack; if there's no_ret_type, U is (), but serde_json gives an + // error when deserializing "" into (), so deserialize 'null' into it + // instead. + // An alternate option would be to require U: Default, and then return + // U::default() here instead since () implements that, but then we'd + // need to impl default for all models. + futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() + } else { + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() + } + })) + } +} diff --git a/src/apis/search_api.rs b/src/apis/search_api.rs new file mode 100755 index 0000000..f9ad6ce --- /dev/null +++ b/src/apis/search_api.rs @@ -0,0 +1,75 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use std::sync::Arc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use hyper_util::client::legacy::connect::Connect; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct SearchApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Arc>, +} + +impl SearchApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Arc>) -> SearchApiClient { + SearchApiClient { + configuration, + } + } +} + +pub trait SearchApi: Send + Sync { + fn autocomplete(&self, autocomplete_request: models::AutocompleteRequest) -> Pin, Error>> + Send>>; + fn percolate(&self, table: &str, percolate_request: models::PercolateRequest) -> Pin> + Send>>; + fn search(&self, search_request: models::SearchRequest) -> Pin> + Send>>; +} + +implSearchApi for SearchApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn autocomplete(&self, autocomplete_request: models::AutocompleteRequest) -> Pin, Error>> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/autocomplete".to_string()) + ; + req = req.with_body_param(autocomplete_request); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn percolate(&self, table: &str, percolate_request: models::PercolateRequest) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/pq/{table}/search".to_string()) + ; + req = req.with_path_param("table".to_string(), table.to_string()); + req = req.with_body_param(percolate_request); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn search(&self, search_request: models::SearchRequest) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/search".to_string()) + ; + req = req.with_body_param(search_request); + + req.execute(self.configuration.borrow()) + } + +} diff --git a/src/apis/utils_api.rs b/src/apis/utils_api.rs new file mode 100755 index 0000000..5f82886 --- /dev/null +++ b/src/apis/utils_api.rs @@ -0,0 +1,58 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use std::sync::Arc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use hyper_util::client::legacy::connect::Connect; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct UtilsApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Arc>, +} + +impl UtilsApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Arc>) -> UtilsApiClient { + UtilsApiClient { + configuration, + } + } +} + +pub trait UtilsApi: Send + Sync { + fn sql(&self, body: &str, raw_response: Option) -> Pin> + Send>>; +} + +implUtilsApi for UtilsApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn sql(&self, body: &str, raw_response: Option) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/sql".to_string()) + ; + if let Some(ref s) = raw_response { + let query_value = s.to_string(); + req = req.with_query_param("raw_response".to_string(), query_value); + } + req = req.with_body_param(body); + + req.execute(self.configuration.borrow()) + } + +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100755 index 0000000..f5cfd23 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,12 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde_repr; +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate hyper; +extern crate futures; + +pub mod apis; +pub mod models; diff --git a/src/models/_match.rs b/src/models/_match.rs new file mode 100755 index 0000000..6e35716 --- /dev/null +++ b/src/models/_match.rs @@ -0,0 +1,49 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Match : Filter helper object defining a match keyword and match options +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Match { + #[serde(rename = "query")] + pub query: String, + #[serde(rename = "operator", skip_serializing_if = "Option::is_none")] + pub operator: Option, + #[serde(rename = "boost", skip_serializing_if = "Option::is_none")] + pub boost: Option, +} + +impl Match { + /// Filter helper object defining a match keyword and match options + pub fn new(query: String) -> Match { + Match { + query, + operator: None, + boost: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Operator { + #[serde(rename = "or")] + Or, + #[serde(rename = "and")] + And, +} + +impl Default for Operator { + fn default() -> Operator { + Self::Or + } +} + diff --git a/src/models/agg_composite.rs b/src/models/agg_composite.rs new file mode 100755 index 0000000..0b3d679 --- /dev/null +++ b/src/models/agg_composite.rs @@ -0,0 +1,33 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// AggComposite : Object to perform composite aggregation, i.e., grouping search results by multiple fields +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AggComposite { + /// Maximum number of composite buckets in the result + #[serde(rename = "size", skip_serializing_if = "Option::is_none")] + pub size: Option, + #[serde(rename = "sources", skip_serializing_if = "Option::is_none")] + pub sources: Option>>, +} + +impl AggComposite { + /// Object to perform composite aggregation, i.e., grouping search results by multiple fields + pub fn new() -> AggComposite { + AggComposite { + size: None, + sources: None, + } + } +} + diff --git a/src/models/agg_composite_source.rs b/src/models/agg_composite_source.rs new file mode 100755 index 0000000..5a7f5ef --- /dev/null +++ b/src/models/agg_composite_source.rs @@ -0,0 +1,29 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// AggCompositeSource : Object containing terms used for composite aggregation. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AggCompositeSource { + #[serde(rename = "terms")] + pub terms: Box, +} + +impl AggCompositeSource { + /// Object containing terms used for composite aggregation. + pub fn new(terms: crate::models::AggCompositeTerm) -> AggCompositeSource { + AggCompositeSource { + terms: Box::new(terms), + } + } +} + diff --git a/src/models/agg_composite_term.rs b/src/models/agg_composite_term.rs new file mode 100755 index 0000000..b1118a1 --- /dev/null +++ b/src/models/agg_composite_term.rs @@ -0,0 +1,30 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// AggCompositeTerm : Object representing a term to be used in composite aggregation. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AggCompositeTerm { + /// Name of field to operate with + #[serde(rename = "field")] + pub field: String, +} + +impl AggCompositeTerm { + /// Object representing a term to be used in composite aggregation. + pub fn new(field: String) -> AggCompositeTerm { + AggCompositeTerm { + field, + } + } +} + diff --git a/src/models/agg_terms.rs b/src/models/agg_terms.rs new file mode 100755 index 0000000..c0980d2 --- /dev/null +++ b/src/models/agg_terms.rs @@ -0,0 +1,34 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// AggTerms : Object containing term fields to aggregate on +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AggTerms { + /// Name of attribute to aggregate by + #[serde(rename = "field")] + pub field: String, + /// Maximum number of buckets in the result + #[serde(rename = "size", skip_serializing_if = "Option::is_none")] + pub size: Option, +} + +impl AggTerms { + /// Object containing term fields to aggregate on + pub fn new(field: String) -> AggTerms { + AggTerms { + field, + size: None, + } + } +} + diff --git a/src/models/aggregation.rs b/src/models/aggregation.rs new file mode 100755 index 0000000..0fc86bd --- /dev/null +++ b/src/models/aggregation.rs @@ -0,0 +1,33 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Aggregation { + #[serde(rename = "terms", skip_serializing_if = "Option::is_none")] + pub terms: Option>, + #[serde(rename = "sort", skip_serializing_if = "Option::is_none")] + pub sort: Option>, + #[serde(rename = "composite", skip_serializing_if = "Option::is_none")] + pub composite: Option>, +} + +impl Aggregation { + pub fn new() -> Aggregation { + Aggregation { + terms: None, + sort: None, + composite: None, + } + } +} + diff --git a/src/models/autocomplete_request.rs b/src/models/autocomplete_request.rs new file mode 100755 index 0000000..46a6f57 --- /dev/null +++ b/src/models/autocomplete_request.rs @@ -0,0 +1,38 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// AutocompleteRequest : Object containing the data for performing an autocomplete search. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AutocompleteRequest { + /// The table to perform the search on + #[serde(rename = "table")] + pub table: String, + /// The beginning of the string to autocomplete + #[serde(rename = "query")] + pub query: String, + /// Autocomplete options - layouts: A comma-separated string of keyboard layout codes to validate and check for spell correction. Available options - us, ru, ua, se, pt, no, it, gr, uk, fr, es, dk, de, ch, br, bg, be. By default, all are enabled. - fuzziness: (0,1 or 2) Maximum Levenshtein distance for finding typos. Set to 0 to disable fuzzy matching. Default is 2 - prepend: true/false If true, adds an asterisk before the last word for prefix expansion (e.g., *word ) - append: true/false If true, adds an asterisk after the last word for prefix expansion (e.g., word* ) - expansion_len: Number of characters to expand in the last word. Default is 10. + #[serde(rename = "options", skip_serializing_if = "Option::is_none")] + pub options: Option, +} + +impl AutocompleteRequest { + /// Object containing the data for performing an autocomplete search. + pub fn new(table: String, query: String) -> AutocompleteRequest { + AutocompleteRequest { + table, + query, + options: None, + } + } +} + diff --git a/src/models/bool_filter.rs b/src/models/bool_filter.rs new file mode 100755 index 0000000..bbdf948 --- /dev/null +++ b/src/models/bool_filter.rs @@ -0,0 +1,36 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BoolFilter { + /// Query clauses that must match for the document to be included + #[serde(rename = "must", skip_serializing_if = "Option::is_none")] + pub must: Option>, + /// Query clauses that must not match for the document to be included + #[serde(rename = "must_not", skip_serializing_if = "Option::is_none")] + pub must_not: Option>, + /// Query clauses that should be matched, but are not required + #[serde(rename = "should", skip_serializing_if = "Option::is_none")] + pub should: Option>, +} + +impl BoolFilter { + pub fn new() -> BoolFilter { + BoolFilter { + must: None, + must_not: None, + should: None, + } + } +} + diff --git a/src/models/bulk_response.rs b/src/models/bulk_response.rs new file mode 100755 index 0000000..b3127b0 --- /dev/null +++ b/src/models/bulk_response.rs @@ -0,0 +1,46 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// BulkResponse : Success response for bulk search requests +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BulkResponse { + /// List of results + #[serde(rename = "items", skip_serializing_if = "Option::is_none")] + pub items: Option>, + /// Errors occurred during the bulk operation + #[serde(rename = "errors", skip_serializing_if = "Option::is_none")] + pub errors: Option, + /// Error message describing an error if such occurred + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + /// Number of the row returned in the response + #[serde(rename = "current_line", skip_serializing_if = "Option::is_none")] + pub current_line: Option, + /// Number of rows skipped in the response + #[serde(rename = "skipped_lines", skip_serializing_if = "Option::is_none")] + pub skipped_lines: Option, +} + +impl BulkResponse { + /// Success response for bulk search requests + pub fn new() -> BulkResponse { + BulkResponse { + items: None, + errors: None, + error: None, + current_line: None, + skipped_lines: None, + } + } +} + diff --git a/src/models/delete_document_request.rs b/src/models/delete_document_request.rs new file mode 100755 index 0000000..da5ece3 --- /dev/null +++ b/src/models/delete_document_request.rs @@ -0,0 +1,42 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// DeleteDocumentRequest : Payload for delete request. Documents can be deleted either one by one by specifying the document id or by providing a query object. For more information see [Delete API](https://manual.manticoresearch.com/Deleting_documents) +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DeleteDocumentRequest { + /// Table name + #[serde(rename = "table")] + pub table: String, + /// Cluster name + #[serde(rename = "cluster", skip_serializing_if = "Option::is_none")] + pub cluster: Option, + /// The ID of document for deletion + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Defines the criteria to match documents for deletion + #[serde(rename = "query", skip_serializing_if = "Option::is_none")] + pub query: Option, +} + +impl DeleteDocumentRequest { + /// Payload for delete request. Documents can be deleted either one by one by specifying the document id or by providing a query object. For more information see [Delete API](https://manual.manticoresearch.com/Deleting_documents) + pub fn new(table: String) -> DeleteDocumentRequest { + DeleteDocumentRequest { + table, + cluster: None, + id: None, + query: None, + } + } +} + diff --git a/src/models/delete_response.rs b/src/models/delete_response.rs new file mode 100755 index 0000000..6719a6e --- /dev/null +++ b/src/models/delete_response.rs @@ -0,0 +1,46 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// DeleteResponse : Response object for successful delete request +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DeleteResponse { + /// The name of the table from which the document was deleted + #[serde(rename = "table", skip_serializing_if = "Option::is_none")] + pub table: Option, + /// Number of documents deleted + #[serde(rename = "deleted", skip_serializing_if = "Option::is_none")] + pub deleted: Option, + /// The ID of the deleted document. If multiple documents are deleted, the ID of the first deleted document is returned + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Indicates whether any documents to be deleted were found + #[serde(rename = "found", skip_serializing_if = "Option::is_none")] + pub found: Option, + /// Result of the delete operation, typically 'deleted' + #[serde(rename = "result", skip_serializing_if = "Option::is_none")] + pub result: Option, +} + +impl DeleteResponse { + /// Response object for successful delete request + pub fn new() -> DeleteResponse { + DeleteResponse { + table: None, + deleted: None, + id: None, + found: None, + result: None, + } + } +} + diff --git a/src/models/error_response.rs b/src/models/error_response.rs new file mode 100755 index 0000000..425758a --- /dev/null +++ b/src/models/error_response.rs @@ -0,0 +1,33 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ErrorResponse : Error response object containing information about the error and a status code +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ErrorResponse { + #[serde(rename = "error")] + pub error: Box, + /// HTTP status code of the error response + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl ErrorResponse { + /// Error response object containing information about the error and a status code + pub fn new(error: crate::models::ResponseError) -> ErrorResponse { + ErrorResponse { + error: Box::new(error), + status: None, + } + } +} + diff --git a/src/models/fulltext_filter.rs b/src/models/fulltext_filter.rs new file mode 100755 index 0000000..6adc29b --- /dev/null +++ b/src/models/fulltext_filter.rs @@ -0,0 +1,42 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// FulltextFilter : Defines a type of filter for full-text search queries +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FulltextFilter { + /// Filter object defining a query string + #[serde(rename = "query_string", skip_serializing_if = "Option::is_none")] + pub query_string: Option, + /// Filter object defining a match keyword passed as a string or in a Match object + #[serde(rename = "match", skip_serializing_if = "Option::is_none")] + pub r#match: Option, + /// Filter object defining a match phrase + #[serde(rename = "match_phrase", skip_serializing_if = "Option::is_none")] + pub match_phrase: Option, + /// Filter object to select all documents + #[serde(rename = "match_all", skip_serializing_if = "Option::is_none")] + pub match_all: Option, +} + +impl FulltextFilter { + /// Defines a type of filter for full-text search queries + pub fn new() -> FulltextFilter { + FulltextFilter { + query_string: None, + r#match: None, + match_phrase: None, + match_all: None, + } + } +} + diff --git a/src/models/geo_distance.rs b/src/models/geo_distance.rs new file mode 100755 index 0000000..0f09c7b --- /dev/null +++ b/src/models/geo_distance.rs @@ -0,0 +1,55 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// GeoDistance : Object to perform geo-distance based filtering on queries +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GeoDistance { + #[serde(rename = "location_anchor", skip_serializing_if = "Option::is_none")] + pub location_anchor: Option>, + /// Field name in the document that contains location data + #[serde(rename = "location_source", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub location_source: Option>, + /// Algorithm used to calculate the distance + #[serde(rename = "distance_type", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub distance_type: Option>, + /// The distance from the anchor point to filter results by + #[serde(rename = "distance", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub distance: Option>, +} + +impl GeoDistance { + /// Object to perform geo-distance based filtering on queries + pub fn new() -> GeoDistance { + GeoDistance { + location_anchor: None, + location_source: None, + distance_type: None, + distance: None, + } + } +} +/// Algorithm used to calculate the distance +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum DistanceType { + #[serde(rename = "adaptive")] + Adaptive, + #[serde(rename = "haversine")] + Haversine, +} + +impl Default for DistanceType { + fn default() -> DistanceType { + Self::Adaptive + } +} + diff --git a/src/models/geo_distance_location_anchor.rs b/src/models/geo_distance_location_anchor.rs new file mode 100755 index 0000000..2f1dabf --- /dev/null +++ b/src/models/geo_distance_location_anchor.rs @@ -0,0 +1,34 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// GeoDistanceLocationAnchor : Specifies the location of the pin point used for search +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GeoDistanceLocationAnchor { + /// Latitude of the anchor point + #[serde(rename = "lat", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub lat: Option>, + /// Longitude of the anchor point + #[serde(rename = "lon", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub lon: Option>, +} + +impl GeoDistanceLocationAnchor { + /// Specifies the location of the pin point used for search + pub fn new() -> GeoDistanceLocationAnchor { + GeoDistanceLocationAnchor { + lat: None, + lon: None, + } + } +} + diff --git a/src/models/highlight.rs b/src/models/highlight.rs new file mode 100755 index 0000000..9eebffd --- /dev/null +++ b/src/models/highlight.rs @@ -0,0 +1,176 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Highlight { + /// Maximum size of the text fragments in highlighted snippets per field + #[serde(rename = "fragment_size", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub fragment_size: Option>, + /// Maximum size of snippets per field + #[serde(rename = "limit", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub limit: Option>, + /// Maximum number of snippets per field + #[serde(rename = "limit_snippets", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub limit_snippets: Option>, + /// Maximum number of words per field + #[serde(rename = "limit_words", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub limit_words: Option>, + /// Total number of highlighted fragments per field + #[serde(rename = "number_of_fragments", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub number_of_fragments: Option>, + /// Text inserted after the matched term, typically used for HTML formatting + #[serde(rename = "after_match", skip_serializing_if = "Option::is_none")] + pub after_match: Option, + /// Permits an empty string to be returned as the highlighting result. Otherwise, the beginning of the original text would be returned + #[serde(rename = "allow_empty", skip_serializing_if = "Option::is_none")] + pub allow_empty: Option, + /// Number of words around the match to include in the highlight + #[serde(rename = "around", skip_serializing_if = "Option::is_none")] + pub around: Option, + /// Text inserted before the match, typically used for HTML formatting + #[serde(rename = "before_match", skip_serializing_if = "Option::is_none")] + pub before_match: Option, + /// Emits an HTML tag with the enclosing zone name before each highlighted snippet + #[serde(rename = "emit_zones", skip_serializing_if = "Option::is_none")] + pub emit_zones: Option, + /// If set to 'html', retains HTML markup when highlighting + #[serde(rename = "encoder", skip_serializing_if = "Option::is_none")] + pub encoder: Option, + #[serde(rename = "fields", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub fields: Option>, + /// Ignores the length limit until the result includes all keywords + #[serde(rename = "force_all_words", skip_serializing_if = "Option::is_none")] + pub force_all_words: Option, + /// Forces snippet generation even if limits allow highlighting the entire text + #[serde(rename = "force_snippets", skip_serializing_if = "Option::is_none")] + pub force_snippets: Option, + #[serde(rename = "highlight_query", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub highlight_query: Option>>, + /// Defines the mode for handling HTML markup in the highlight + #[serde(rename = "html_strip_mode", skip_serializing_if = "Option::is_none")] + pub html_strip_mode: Option, + /// Determines whether the 'limit', 'limit_words', and 'limit_snippets' options operate as individual limits in each field of the document + #[serde(rename = "limits_per_field", skip_serializing_if = "Option::is_none")] + pub limits_per_field: Option, + /// If set to 1, allows an empty string to be returned as a highlighting result + #[serde(rename = "no_match_size", skip_serializing_if = "Option::is_none")] + pub no_match_size: Option, + /// Sets the sorting order of highlighted snippets + #[serde(rename = "order", skip_serializing_if = "Option::is_none")] + pub order: Option, + /// Text inserted before each highlighted snippet + #[serde(rename = "pre_tags", skip_serializing_if = "Option::is_none")] + pub pre_tags: Option, + /// Text inserted after each highlighted snippet + #[serde(rename = "post_tags", skip_serializing_if = "Option::is_none")] + pub post_tags: Option, + /// Sets the starting value of the %SNIPPET_ID% macro + #[serde(rename = "start_snippet_id", skip_serializing_if = "Option::is_none")] + pub start_snippet_id: Option, + /// Defines whether to additionally break snippets by phrase boundary characters + #[serde(rename = "use_boundaries", skip_serializing_if = "Option::is_none")] + pub use_boundaries: Option, +} + +impl Highlight { + pub fn new() -> Highlight { + Highlight { + fragment_size: None, + limit: None, + limit_snippets: None, + limit_words: None, + number_of_fragments: None, + after_match: None, + allow_empty: None, + around: None, + before_match: None, + emit_zones: None, + encoder: None, + fields: None, + force_all_words: None, + force_snippets: None, + highlight_query: None, + html_strip_mode: None, + limits_per_field: None, + no_match_size: None, + order: None, + pre_tags: None, + post_tags: None, + start_snippet_id: None, + use_boundaries: None, + } + } +} +/// If set to 'html', retains HTML markup when highlighting +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Encoder { + #[serde(rename = "default")] + Default, + #[serde(rename = "html")] + Html, +} + +impl Default for Encoder { + fn default() -> Encoder { + Self::Default + } +} +/// Defines the mode for handling HTML markup in the highlight +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum HtmlStripMode { + #[serde(rename = "none")] + None, + #[serde(rename = "strip")] + Strip, + #[serde(rename = "index")] + Index, + #[serde(rename = "retain")] + Retain, +} + +impl Default for HtmlStripMode { + fn default() -> HtmlStripMode { + Self::None + } +} +/// If set to 1, allows an empty string to be returned as a highlighting result +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum NoMatchSize { + #[serde(rename = "0")] + Variant0, + #[serde(rename = "1")] + Variant1, +} + +impl Default for NoMatchSize { + fn default() -> NoMatchSize { + Self::Variant0 + } +} +/// Sets the sorting order of highlighted snippets +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Order { + #[serde(rename = "asc")] + Asc, + #[serde(rename = "desc")] + Desc, + #[serde(rename = "score")] + Score, +} + +impl Default for Order { + fn default() -> Order { + Self::Asc + } +} + diff --git a/src/models/highlight_field_option.rs b/src/models/highlight_field_option.rs new file mode 100755 index 0000000..e27f854 --- /dev/null +++ b/src/models/highlight_field_option.rs @@ -0,0 +1,46 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// HighlightFieldOption : Options for controlling the behavior of highlighting on a per-field basis +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct HighlightFieldOption { + /// Maximum size of the text fragments in highlighted snippets per field + #[serde(rename = "fragment_size", skip_serializing_if = "Option::is_none")] + pub fragment_size: Option, + /// Maximum size of snippets per field + #[serde(rename = "limit", skip_serializing_if = "Option::is_none")] + pub limit: Option, + /// Maximum number of snippets per field + #[serde(rename = "limit_snippets", skip_serializing_if = "Option::is_none")] + pub limit_snippets: Option, + /// Maximum number of words per field + #[serde(rename = "limit_words", skip_serializing_if = "Option::is_none")] + pub limit_words: Option, + /// Total number of highlighted fragments per field + #[serde(rename = "number_of_fragments", skip_serializing_if = "Option::is_none")] + pub number_of_fragments: Option, +} + +impl HighlightFieldOption { + /// Options for controlling the behavior of highlighting on a per-field basis + pub fn new() -> HighlightFieldOption { + HighlightFieldOption { + fragment_size: None, + limit: None, + limit_snippets: None, + limit_words: None, + number_of_fragments: None, + } + } +} + diff --git a/src/models/hits_hits.rs b/src/models/hits_hits.rs new file mode 100755 index 0000000..27c5bf5 --- /dev/null +++ b/src/models/hits_hits.rs @@ -0,0 +1,58 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// HitsHits : Search hit representing a matched document +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct HitsHits { + /// The ID of the matched document + #[serde(rename = "_id", skip_serializing_if = "Option::is_none")] + pub _id: Option, + /// The score of the matched document + #[serde(rename = "_score", skip_serializing_if = "Option::is_none")] + pub _score: Option, + /// The source data of the matched document + #[serde(rename = "_source", skip_serializing_if = "Option::is_none")] + pub _source: Option, + /// The knn distance of the matched document returned for knn queries + #[serde(rename = "_knn_dist", skip_serializing_if = "Option::is_none")] + pub _knn_dist: Option, + /// The highlighting-related data of the matched document + #[serde(rename = "highlight", skip_serializing_if = "Option::is_none")] + pub highlight: Option, + /// The table name of the matched document returned for percolate queries + #[serde(rename = "table", skip_serializing_if = "Option::is_none")] + pub table: Option, + /// The type of the matched document returned for percolate queries + #[serde(rename = "_type:", skip_serializing_if = "Option::is_none")] + pub _type_colon: Option, + /// The percolate-related fields of the matched document returned for percolate queries + #[serde(rename = "fields", skip_serializing_if = "Option::is_none")] + pub fields: Option, +} + +impl HitsHits { + /// Search hit representing a matched document + pub fn new() -> HitsHits { + HitsHits { + _id: None, + _score: None, + _source: None, + _knn_dist: None, + highlight: None, + table: None, + _type_colon: None, + fields: None, + } + } +} + diff --git a/src/models/insert_document_request.rs b/src/models/insert_document_request.rs new file mode 100755 index 0000000..833deb7 --- /dev/null +++ b/src/models/insert_document_request.rs @@ -0,0 +1,42 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// InsertDocumentRequest : Object containing data for inserting a new document into the table +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct InsertDocumentRequest { + /// Name of the table to insert the document into + #[serde(rename = "table")] + pub table: String, + /// Name of the cluster to insert the document into + #[serde(rename = "cluster", skip_serializing_if = "Option::is_none")] + pub cluster: Option, + /// Document ID. If not provided, an ID will be auto-generated + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Object containing document data + #[serde(rename = "doc")] + pub doc: serde_json::Value, +} + +impl InsertDocumentRequest { + /// Object containing data for inserting a new document into the table + pub fn new(table: String, doc: serde_json::Value) -> InsertDocumentRequest { + InsertDocumentRequest { + table, + cluster: None, + id: None, + doc, + } + } +} + diff --git a/src/models/join.rs b/src/models/join.rs new file mode 100755 index 0000000..9382ef3 --- /dev/null +++ b/src/models/join.rs @@ -0,0 +1,53 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Join { + /// Type of the join operation + #[serde(rename = "type")] + pub r#type: Type, + /// List of objects defining joined tables + #[serde(rename = "on")] + pub on: Vec, + #[serde(rename = "query", skip_serializing_if = "Option::is_none")] + pub query: Option>, + /// Basic table of the join operation + #[serde(rename = "table")] + pub table: String, +} + +impl Join { + pub fn new(r#type: Type, on: Vec, table: String) -> Join { + Join { + r#type, + on, + query: None, + table, + } + } +} +/// Type of the join operation +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "inner")] + Inner, + #[serde(rename = "left")] + Left, +} + +impl Default for Type { + fn default() -> Type { + Self::Inner + } +} + diff --git a/src/models/join_cond.rs b/src/models/join_cond.rs new file mode 100755 index 0000000..c9ecd16 --- /dev/null +++ b/src/models/join_cond.rs @@ -0,0 +1,37 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// JoinCond : Object representing the conditions used to perform the join operation +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct JoinCond { + /// Field to join on + #[serde(rename = "field")] + pub field: String, + /// Joined table + #[serde(rename = "table")] + pub table: String, + #[serde(rename = "type", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub r#type: Option>, +} + +impl JoinCond { + /// Object representing the conditions used to perform the join operation + pub fn new(field: String, table: String) -> JoinCond { + JoinCond { + field, + table, + r#type: None, + } + } +} + diff --git a/src/models/join_on.rs b/src/models/join_on.rs new file mode 100755 index 0000000..1e2b81a --- /dev/null +++ b/src/models/join_on.rs @@ -0,0 +1,45 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct JoinOn { + #[serde(rename = "right", skip_serializing_if = "Option::is_none")] + pub right: Option>, + #[serde(rename = "left", skip_serializing_if = "Option::is_none")] + pub left: Option>, + #[serde(rename = "operator", skip_serializing_if = "Option::is_none")] + pub operator: Option, +} + +impl JoinOn { + pub fn new() -> JoinOn { + JoinOn { + right: None, + left: None, + operator: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Operator { + #[serde(rename = "eq")] + Eq, +} + +impl Default for Operator { + fn default() -> Operator { + Self::Eq + } +} + diff --git a/src/models/knn_query.rs b/src/models/knn_query.rs new file mode 100755 index 0000000..148d4e1 --- /dev/null +++ b/src/models/knn_query.rs @@ -0,0 +1,49 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// KnnQuery : Object representing a k-nearest neighbor search query +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct KnnQuery { + /// Field to perform the k-nearest neighbor search on + #[serde(rename = "field")] + pub field: String, + /// The number of nearest neighbors to return + #[serde(rename = "k")] + pub k: i32, + /// The vector used as input for the KNN search + #[serde(rename = "query_vector", skip_serializing_if = "Option::is_none")] + pub query_vector: Option>, + /// The docuemnt ID used as input for the KNN search + #[serde(rename = "doc_id", skip_serializing_if = "Option::is_none")] + pub doc_id: Option, + /// Optional parameter controlling the accuracy of the search + #[serde(rename = "ef", skip_serializing_if = "Option::is_none")] + pub ef: Option, + #[serde(rename = "filter", skip_serializing_if = "Option::is_none")] + pub filter: Option>, +} + +impl KnnQuery { + /// Object representing a k-nearest neighbor search query + pub fn new(field: String, k: i32) -> KnnQuery { + KnnQuery { + field, + k, + query_vector: None, + doc_id: None, + ef: None, + filter: None, + } + } +} + diff --git a/src/models/match_all.rs b/src/models/match_all.rs new file mode 100755 index 0000000..30f25e7 --- /dev/null +++ b/src/models/match_all.rs @@ -0,0 +1,41 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// MatchAll : Filter helper object defining the 'match all'' condition +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct MatchAll { + #[serde(rename = "_all")] + pub _all: All, +} + +impl MatchAll { + /// Filter helper object defining the 'match all'' condition + pub fn new(_all: All) -> MatchAll { + MatchAll { + _all, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum All { + #[serde(rename = "{}")] + LeftCurlyBracketRightCurlyBracket, +} + +impl Default for All { + fn default() -> All { + Self::LeftCurlyBracketRightCurlyBracket + } +} + diff --git a/src/models/mod.rs b/src/models/mod.rs new file mode 100755 index 0000000..a2d1583 --- /dev/null +++ b/src/models/mod.rs @@ -0,0 +1,82 @@ +pub mod agg_composite; +pub use self::agg_composite::AggComposite; +pub mod agg_composite_source; +pub use self::agg_composite_source::AggCompositeSource; +pub mod agg_composite_term; +pub use self::agg_composite_term::AggCompositeTerm; +pub mod agg_terms; +pub use self::agg_terms::AggTerms; +pub mod aggregation; +pub use self::aggregation::Aggregation; +pub mod autocomplete_request; +pub use self::autocomplete_request::AutocompleteRequest; +pub mod bool_filter; +pub use self::bool_filter::BoolFilter; +pub mod bulk_response; +pub use self::bulk_response::BulkResponse; +pub mod delete_document_request; +pub use self::delete_document_request::DeleteDocumentRequest; +pub mod delete_response; +pub use self::delete_response::DeleteResponse; +pub mod error_response; +pub use self::error_response::ErrorResponse; +pub mod fulltext_filter; +pub use self::fulltext_filter::FulltextFilter; +pub mod geo_distance; +pub use self::geo_distance::GeoDistance; +pub mod geo_distance_location_anchor; +pub use self::geo_distance_location_anchor::GeoDistanceLocationAnchor; +pub mod highlight; +pub use self::highlight::Highlight; +pub mod highlight_field_option; +pub use self::highlight_field_option::HighlightFieldOption; +pub mod hits_hits; +pub use self::hits_hits::HitsHits; +pub mod insert_document_request; +pub use self::insert_document_request::InsertDocumentRequest; +pub mod join; +pub use self::join::Join; +pub mod join_cond; +pub use self::join_cond::JoinCond; +pub mod join_on; +pub use self::join_on::JoinOn; +pub mod knn_query; +pub use self::knn_query::KnnQuery; +pub mod _match; +pub use self::_match::Match; +pub mod match_all; +pub use self::match_all::MatchAll; +pub mod percolate_request; +pub use self::percolate_request::PercolateRequest; +pub mod percolate_request_query; +pub use self::percolate_request_query::PercolateRequestQuery; +pub mod query_filter; +pub use self::query_filter::QueryFilter; +pub mod range; +pub use self::range::Range; +pub mod replace_document_request; +pub use self::replace_document_request::ReplaceDocumentRequest; +pub mod response_error; +pub use self::response_error::ResponseError; +pub mod response_error_details; +pub use self::response_error_details::ResponseErrorDetails; +pub mod search_query; +pub use self::search_query::SearchQuery; +pub mod search_request; +pub use self::search_request::SearchRequest; +pub mod search_response; +pub use self::search_response::SearchResponse; +pub mod search_response_hits; +pub use self::search_response_hits::SearchResponseHits; +pub mod source_rules; +pub use self::source_rules::SourceRules; +pub mod sql_obj_response; +pub use self::sql_obj_response::SqlObjResponse; +pub mod sql_response; +pub use self::sql_response::SqlResponse; +pub mod success_response; +pub use self::success_response::SuccessResponse; +pub mod update_document_request; +pub use self::update_document_request::UpdateDocumentRequest; +pub mod update_response; +pub use self::update_response::UpdateResponse; diff --git a/src/models/percolate_request.rs b/src/models/percolate_request.rs new file mode 100755 index 0000000..594b339 --- /dev/null +++ b/src/models/percolate_request.rs @@ -0,0 +1,29 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PercolateRequest : Object containing the query for percolating documents against stored queries in a percolate table +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PercolateRequest { + #[serde(rename = "query")] + pub query: Box, +} + +impl PercolateRequest { + /// Object containing the query for percolating documents against stored queries in a percolate table + pub fn new(query: crate::models::PercolateRequestQuery) -> PercolateRequest { + PercolateRequest { + query: Box::new(query), + } + } +} + diff --git a/src/models/percolate_request_query.rs b/src/models/percolate_request_query.rs new file mode 100755 index 0000000..9203a51 --- /dev/null +++ b/src/models/percolate_request_query.rs @@ -0,0 +1,28 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PercolateRequestQuery { + /// Object representing the document to percolate + #[serde(rename = "percolate")] + pub percolate: serde_json::Value, +} + +impl PercolateRequestQuery { + pub fn new(percolate: serde_json::Value) -> PercolateRequestQuery { + PercolateRequestQuery { + percolate, + } + } +} + diff --git a/src/models/query_filter.rs b/src/models/query_filter.rs new file mode 100755 index 0000000..6cb5db6 --- /dev/null +++ b/src/models/query_filter.rs @@ -0,0 +1,59 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// QueryFilter : Object used to apply various conditions, such as full-text matching or attribute filtering, to a search query +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct QueryFilter { + /// Filter object defining a query string + #[serde(rename = "query_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub query_string: Option>, + /// Filter object defining a match keyword passed as a string or in a Match object + #[serde(rename = "match", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub r#match: Option>, + /// Filter object defining a match phrase + #[serde(rename = "match_phrase", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub match_phrase: Option>, + /// Filter object to select all documents + #[serde(rename = "match_all", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub match_all: Option>, + #[serde(rename = "bool", skip_serializing_if = "Option::is_none")] + pub bool: Option>, + #[serde(rename = "equals", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub equals: Option>, + /// Filter to match a given set of attribute values. + #[serde(rename = "in", skip_serializing_if = "Option::is_none")] + pub r#in: Option, + /// Filter to match a given range of attribute values passed in Range objects + #[serde(rename = "range", skip_serializing_if = "Option::is_none")] + pub range: Option, + #[serde(rename = "geo_distance", skip_serializing_if = "Option::is_none")] + pub geo_distance: Option>, +} + +impl QueryFilter { + /// Object used to apply various conditions, such as full-text matching or attribute filtering, to a search query + pub fn new() -> QueryFilter { + QueryFilter { + query_string: None, + r#match: None, + match_phrase: None, + match_all: None, + bool: None, + equals: None, + r#in: None, + range: None, + geo_distance: None, + } + } +} + diff --git a/src/models/range.rs b/src/models/range.rs new file mode 100755 index 0000000..22298b0 --- /dev/null +++ b/src/models/range.rs @@ -0,0 +1,38 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Range : Filter helper object defining the 'range' condition +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Range { + #[serde(rename = "lt", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub lt: Option>, + #[serde(rename = "lte", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub lte: Option>, + #[serde(rename = "gt", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub gt: Option>, + #[serde(rename = "gte", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub gte: Option>, +} + +impl Range { + /// Filter helper object defining the 'range' condition + pub fn new() -> Range { + Range { + lt: None, + lte: None, + gt: None, + gte: None, + } + } +} + diff --git a/src/models/replace_document_request.rs b/src/models/replace_document_request.rs new file mode 100755 index 0000000..61541e9 --- /dev/null +++ b/src/models/replace_document_request.rs @@ -0,0 +1,30 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ReplaceDocumentRequest : Object containing the document data for replacing an existing document in a table. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ReplaceDocumentRequest { + /// Object containing the new document data to replace the existing one. + #[serde(rename = "doc")] + pub doc: serde_json::Value, +} + +impl ReplaceDocumentRequest { + /// Object containing the document data for replacing an existing document in a table. + pub fn new(doc: serde_json::Value) -> ReplaceDocumentRequest { + ReplaceDocumentRequest { + doc, + } + } +} + diff --git a/src/models/response_error.rs b/src/models/response_error.rs new file mode 100755 index 0000000..f30b9d6 --- /dev/null +++ b/src/models/response_error.rs @@ -0,0 +1,27 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ResponseError { + one_of_0(Box), + /// Error message text returned in case of an error + one_of_1(String), +} + +impl Default for ResponseError { + fn default() -> Self { + Self::one_of_0(Default::default()) + } +} + diff --git a/src/models/response_error_details.rs b/src/models/response_error_details.rs new file mode 100755 index 0000000..f922981 --- /dev/null +++ b/src/models/response_error_details.rs @@ -0,0 +1,38 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ResponseErrorDetails : Detailed error information returned in case of an error response +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ResponseErrorDetails { + /// Type or category of the error + #[serde(rename = "type")] + pub r#type: String, + /// Detailed explanation of why the error occurred + #[serde(rename = "reason", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub reason: Option>, + /// The table related to the error, if applicable + #[serde(rename = "table", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub table: Option>, +} + +impl ResponseErrorDetails { + /// Detailed error information returned in case of an error response + pub fn new(r#type: String) -> ResponseErrorDetails { + ResponseErrorDetails { + r#type, + reason: None, + table: None, + } + } +} + diff --git a/src/models/search_query.rs b/src/models/search_query.rs new file mode 100755 index 0000000..235d9a1 --- /dev/null +++ b/src/models/search_query.rs @@ -0,0 +1,62 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SearchQuery : Defines a query structure for performing search operations +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SearchQuery { + /// Filter object defining a query string + #[serde(rename = "query_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub query_string: Option>, + /// Filter object defining a match keyword passed as a string or in a Match object + #[serde(rename = "match", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub r#match: Option>, + /// Filter object defining a match phrase + #[serde(rename = "match_phrase", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub match_phrase: Option>, + /// Filter object to select all documents + #[serde(rename = "match_all", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub match_all: Option>, + #[serde(rename = "bool", skip_serializing_if = "Option::is_none")] + pub bool: Option>, + #[serde(rename = "equals", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub equals: Option>, + /// Filter to match a given set of attribute values. + #[serde(rename = "in", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub r#in: Option>, + /// Filter to match a given range of attribute values passed in Range objects + #[serde(rename = "range", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub range: Option>, + #[serde(rename = "geo_distance", skip_serializing_if = "Option::is_none")] + pub geo_distance: Option>, + #[serde(rename = "highlight", skip_serializing_if = "Option::is_none")] + pub highlight: Option>, +} + +impl SearchQuery { + /// Defines a query structure for performing search operations + pub fn new() -> SearchQuery { + SearchQuery { + query_string: None, + r#match: None, + match_phrase: None, + match_all: None, + bool: None, + equals: None, + r#in: None, + range: None, + geo_distance: None, + highlight: None, + } + } +} + diff --git a/src/models/search_request.rs b/src/models/search_request.rs new file mode 100755 index 0000000..abf4a5f --- /dev/null +++ b/src/models/search_request.rs @@ -0,0 +1,81 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SearchRequest : Request object for search operation +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SearchRequest { + /// The table to perform the search on + #[serde(rename = "table")] + pub table: String, + #[serde(rename = "query", skip_serializing_if = "Option::is_none")] + pub query: Option>, + /// Join clause to combine search data from multiple tables + #[serde(rename = "join", skip_serializing_if = "Option::is_none")] + pub join: Option>, + #[serde(rename = "highlight", skip_serializing_if = "Option::is_none")] + pub highlight: Option>, + /// Maximum number of results to return + #[serde(rename = "limit", skip_serializing_if = "Option::is_none")] + pub limit: Option, + #[serde(rename = "knn", skip_serializing_if = "Option::is_none")] + pub knn: Option>, + /// Defines aggregation settings for grouping results + #[serde(rename = "aggs", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub aggs: Option>>, + /// Expressions to calculate additional values for the result + #[serde(rename = "expressions", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub expressions: Option>>, + /// Maximum number of matches allowed in the result + #[serde(rename = "max_matches", skip_serializing_if = "Option::is_none")] + pub max_matches: Option, + /// Starting point for pagination of the result + #[serde(rename = "offset", skip_serializing_if = "Option::is_none")] + pub offset: Option, + /// Additional search options + #[serde(rename = "options", skip_serializing_if = "Option::is_none")] + pub options: Option, + /// Enable or disable profiling of the search request + #[serde(rename = "profile", skip_serializing_if = "Option::is_none")] + pub profile: Option, + #[serde(rename = "sort", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub sort: Option>, + #[serde(rename = "_source", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub _source: Option>, + /// Enable or disable result weight calculation used for sorting + #[serde(rename = "track_scores", skip_serializing_if = "Option::is_none")] + pub track_scores: Option, +} + +impl SearchRequest { + /// Request object for search operation + pub fn new(table: String) -> SearchRequest { + SearchRequest { + table, + query: None, + join: None, + highlight: None, + limit: None, + knn: None, + aggs: None, + expressions: None, + max_matches: None, + offset: None, + options: None, + profile: None, + sort: None, + _source: None, + track_scores: None, + } + } +} + diff --git a/src/models/search_response.rs b/src/models/search_response.rs new file mode 100755 index 0000000..08538c3 --- /dev/null +++ b/src/models/search_response.rs @@ -0,0 +1,53 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SearchResponse : Response object containing the results of a search request +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SearchResponse { + /// Time taken to execute the search + #[serde(rename = "took", skip_serializing_if = "Option::is_none")] + pub took: Option, + /// Indicates whether the search operation timed out + #[serde(rename = "timed_out", skip_serializing_if = "Option::is_none")] + pub timed_out: Option, + /// Aggregated search results grouped by the specified criteria + #[serde(rename = "aggregations", skip_serializing_if = "Option::is_none")] + pub aggregations: Option, + #[serde(rename = "hits", skip_serializing_if = "Option::is_none")] + pub hits: Option>, + /// Profile information about the search execution, if profiling is enabled + #[serde(rename = "profile", skip_serializing_if = "Option::is_none")] + pub profile: Option, + /// Scroll token to be used fo pagination + #[serde(rename = "scroll", skip_serializing_if = "Option::is_none")] + pub scroll: Option, + /// Warnings encountered during the search operation + #[serde(rename = "warning", skip_serializing_if = "Option::is_none")] + pub warning: Option, +} + +impl SearchResponse { + /// Response object containing the results of a search request + pub fn new() -> SearchResponse { + SearchResponse { + took: None, + timed_out: None, + aggregations: None, + hits: None, + profile: None, + scroll: None, + warning: None, + } + } +} + diff --git a/src/models/search_response_hits.rs b/src/models/search_response_hits.rs new file mode 100755 index 0000000..107c69e --- /dev/null +++ b/src/models/search_response_hits.rs @@ -0,0 +1,42 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SearchResponseHits : Object containing the search hits, which represent the documents that matched the query. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SearchResponseHits { + /// Maximum score among the matched documents + #[serde(rename = "max_score", skip_serializing_if = "Option::is_none")] + pub max_score: Option, + /// Total number of matched documents + #[serde(rename = "total", skip_serializing_if = "Option::is_none")] + pub total: Option, + /// Indicates whether the total number of hits is accurate or an estimate + #[serde(rename = "total_relation", skip_serializing_if = "Option::is_none")] + pub total_relation: Option, + /// Array of hit objects, each representing a matched document + #[serde(rename = "hits", skip_serializing_if = "Option::is_none")] + pub hits: Option>, +} + +impl SearchResponseHits { + /// Object containing the search hits, which represent the documents that matched the query. + pub fn new() -> SearchResponseHits { + SearchResponseHits { + max_score: None, + total: None, + total_relation: None, + hits: None, + } + } +} + diff --git a/src/models/source_rules.rs b/src/models/source_rules.rs new file mode 100755 index 0000000..98ec1dd --- /dev/null +++ b/src/models/source_rules.rs @@ -0,0 +1,34 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SourceRules : Defines which fields to include or exclude in the response for a search query +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SourceRules { + /// List of fields to include in the response + #[serde(rename = "includes", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub includes: Option>, + /// List of fields to exclude from the response + #[serde(rename = "excludes", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub excludes: Option>, +} + +impl SourceRules { + /// Defines which fields to include or exclude in the response for a search query + pub fn new() -> SourceRules { + SourceRules { + includes: None, + excludes: None, + } + } +} + diff --git a/src/models/sql_obj_response.rs b/src/models/sql_obj_response.rs new file mode 100755 index 0000000..aab45d5 --- /dev/null +++ b/src/models/sql_obj_response.rs @@ -0,0 +1,27 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SqlObjResponse { + #[serde(rename = "hits")] + pub hits: serde_json::Value, +} + +impl SqlObjResponse { + pub fn new(hits: serde_json::Value) -> SqlObjResponse { + SqlObjResponse { + hits, + } + } +} + diff --git a/src/models/sql_response.rs b/src/models/sql_response.rs new file mode 100755 index 0000000..64cc0e7 --- /dev/null +++ b/src/models/sql_response.rs @@ -0,0 +1,28 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SqlResponse : List of responses from executed SQL queries +/// List of responses from executed SQL queries +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SqlResponse { + one_of_0(Vec), + one_of_1(Box), +} + +impl Default for SqlResponse { + fn default() -> Self { + Self::one_of_0(Default::default()) + } +} + diff --git a/src/models/success_response.rs b/src/models/success_response.rs new file mode 100755 index 0000000..d99290b --- /dev/null +++ b/src/models/success_response.rs @@ -0,0 +1,50 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SuccessResponse : Response object indicating the success of an operation, such as inserting or updating a document +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SuccessResponse { + /// Name of the document table + #[serde(rename = "table", skip_serializing_if = "Option::is_none")] + pub table: Option, + /// ID of the document affected by the request operation + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Indicates whether the document was created as a result of the operation + #[serde(rename = "created", skip_serializing_if = "Option::is_none")] + pub created: Option, + /// Result of the operation, typically 'created', 'updated', or 'deleted' + #[serde(rename = "result", skip_serializing_if = "Option::is_none")] + pub result: Option, + /// Indicates whether the document was found in the table + #[serde(rename = "found", skip_serializing_if = "Option::is_none")] + pub found: Option, + /// HTTP status code representing the result of the operation + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl SuccessResponse { + /// Response object indicating the success of an operation, such as inserting or updating a document + pub fn new() -> SuccessResponse { + SuccessResponse { + table: None, + id: None, + created: None, + result: None, + found: None, + status: None, + } + } +} + diff --git a/src/models/update_document_request.rs b/src/models/update_document_request.rs new file mode 100755 index 0000000..4750ba8 --- /dev/null +++ b/src/models/update_document_request.rs @@ -0,0 +1,45 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// UpdateDocumentRequest : Payload for updating a document or multiple documents in a table +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateDocumentRequest { + /// Name of the document table + #[serde(rename = "table")] + pub table: String, + /// Name of the document cluster + #[serde(rename = "cluster", skip_serializing_if = "Option::is_none")] + pub cluster: Option, + /// Object containing the document fields to update + #[serde(rename = "doc")] + pub doc: serde_json::Value, + /// Document ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "query", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub query: Option>>, +} + +impl UpdateDocumentRequest { + /// Payload for updating a document or multiple documents in a table + pub fn new(table: String, doc: serde_json::Value) -> UpdateDocumentRequest { + UpdateDocumentRequest { + table, + cluster: None, + doc, + id: None, + query: None, + } + } +} + diff --git a/src/models/update_response.rs b/src/models/update_response.rs new file mode 100755 index 0000000..99cc8f1 --- /dev/null +++ b/src/models/update_response.rs @@ -0,0 +1,42 @@ +/* + * Manticore Search Client + * + * Сlient for Manticore Search. + * + * The version of the OpenAPI document: 5.0.0 + * Contact: info@manticoresearch.com + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// UpdateResponse : Success response returned after updating one or more documents +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateResponse { + /// Name of the document table + #[serde(rename = "table", skip_serializing_if = "Option::is_none")] + pub table: Option, + /// Number of documents updated + #[serde(rename = "updated", skip_serializing_if = "Option::is_none")] + pub updated: Option, + /// Document ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Result of the update operation, typically 'updated' + #[serde(rename = "result", skip_serializing_if = "Option::is_none")] + pub result: Option, +} + +impl UpdateResponse { + /// Success response returned after updating one or more documents + pub fn new() -> UpdateResponse { + UpdateResponse { + table: None, + updated: None, + id: None, + result: None, + } + } +} + diff --git a/tests/index_api.rs b/tests/index_api.rs new file mode 100755 index 0000000..6987a36 --- /dev/null +++ b/tests/index_api.rs @@ -0,0 +1,78 @@ +use std::sync::Arc; +use tokio; +use manticoresearch::{ + apis::{configuration::Configuration, UtilsApi, UtilsApiClient, IndexApi, IndexApiClient}, + models::InsertDocumentRequest, models::SqlResponse, +}; +use std::collections::HashMap; + +#[tokio::test] +async fn index_api_basic_requests() { + let api_config = Arc::new(Configuration::new()); + let utils_api = UtilsApiClient::new(api_config.clone()); + let index_api = IndexApiClient::new(api_config.clone()); + + // Drop the table if it exists + let res = utils_api.sql("DROP TABLE IF EXISTS products", Some(true)).await; + assert!(res.is_ok(), "DROP TABLE failed: {:?}", res.err()); + + // Create table + let res = utils_api + .sql( + "CREATE TABLE IF NOT EXISTS products (title text, price float, sizes multi, meta json, coeff float, tags1 multi, tags2 multi)", + Some(true), + ) + .await; + assert!(res.is_ok(), "Failed to create table: {:?}", res.err()); + + // Prepare document + let mut doc = HashMap::new(); + doc.insert("title".to_string(), serde_json::json!("test")); + doc.insert("tags1".to_string(), serde_json::json!([1, 2, 4, 5])); + + // Insert without specifying ID + let insert_req = InsertDocumentRequest::new("products".to_string(), serde_json::json!(doc)); + let res = index_api.insert(insert_req).await; + assert!(res.is_ok(), "Failed to insert document without ID: {:?}", res.err()); + + // Insert with specific ID + let mut insert_req = InsertDocumentRequest::new("products".to_string(), serde_json::json!(doc)); + insert_req.id = Some(100); + let res = index_api.insert(insert_req).await; + assert!(res.is_ok(), "Failed to insert document with ID: {:?}", res.err()); + + let insert_response = res.unwrap(); + println!("Insert response with ID 100: {:?}", insert_response); + + // Drop the table if it exists + let res = utils_api.sql("DROP TABLE IF EXISTS products", Some(true)).await; + assert!(res.is_ok(), "DROP TABLE failed: {:?}", res.err()); + + + // Create table + let res = utils_api + .sql( + "CREATE TABLE IF NOT EXISTS products (title text, price float, sizes multi, meta json, coeff float, tags1 multi, tags2 multi)", + Some(true), + ) + .await; + assert!(res.is_ok(), "Failed to create table: {:?}", res.err()); + + // Bulk insert + let insert_body = r#"{"insert": {"table": "products", "id": 3, "doc": {"title": "Crossbody \"Bag with Tassel", "price": 19.85}}} +{"insert": {"table": "products", "id": 4, "doc": {"title": "microfiber sheet set", "price": 19.99}}} +{"insert": {"table": "products", "id": 5, "doc": {"title": "CPet Hair Remover Glove", "price": 7.99}}} +"#; + let res = index_api.bulk(insert_body).await; + assert!(res.is_ok(), "Bulk insert failed: {:?}", res.err()); + + let bulk_insert_response = res.unwrap(); + println!("Bulk insert response with ID 100: {:?}", bulk_insert_response); + + // Bulk update + let update_body = r#"{"update": { "table" : "products", "doc": { "coeff" : 1000 }, "query": { "range": { "price": { "gte": 1000 } } } } } +{ "update" : { "table" : "products", "doc": { "coeff" : 0 }, "query": { "range": { "price": { "lt": 1000 } } } } } +"#; + let res = index_api.bulk(update_body).await; + assert!(res.is_ok(), "Bulk update failed: {:?}", res.err()); +} \ No newline at end of file diff --git a/tests/search_api.rs b/tests/search_api.rs new file mode 100755 index 0000000..5f231a3 --- /dev/null +++ b/tests/search_api.rs @@ -0,0 +1,72 @@ +use std::sync::Arc; +use manticoresearch::{ + apis::{ + {configuration::Configuration,IndexApi,IndexApiClient,SearchApi,SearchApiClient,UtilsApi,UtilsApiClient} + }, + models::{SearchRequest,SearchQuery,Highlight} +}; +use std::collections::HashMap; +use tokio; + +#[tokio::test] +async fn search_api_basic_requests() { + let api_config = Arc::new(Configuration::new()); + let utils_api = UtilsApiClient::new(api_config.clone()); + let index_api = IndexApiClient::new(api_config.clone()); + let search_api = SearchApiClient::new(api_config.clone()); + + // Drop table if it exists + let res = utils_api.sql("DROP TABLE IF EXISTS movies", Some(true)).await; + assert!(res.is_ok(), "Failed to drop table: {:?}", res.err()); + + // Create table + let res = utils_api + .sql( + "CREATE TABLE IF NOT EXISTS movies (title text, plot text, _year integer, rating float, cat string, code multi, type_vector float_vector knn_type='hnsw' knn_dims='3' hnsw_similarity='l2')", + Some(true), + ) + .await; + assert!(res.is_ok(), "Failed to create table: {:?}", res.err()); + + // Bulk insert documents + let bulk_body = r#"{"insert": {"table" : "movies", "id" : 1, "doc" : {"title" : "Star Trek 2: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2002, "rating": 6.4, "cat": "R", "code": [1,2,3], "type_vector": [0.2, 1.4, -2.3]}}} +{"insert": {"table" : "movies", "id" : 2, "doc" : {"title" : "Star Trek 1: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2001, "rating": 6.5, "cat": "PG-13", "code": [1,12,3], "type_vector": [0.8, 0.4, 1.3]}}} +{"insert": {"table" : "movies", "id" : 3, "doc" : {"title" : "Star Trek 3: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2003, "rating": 6.6, "cat": "R", "code": [11,2,3], "type_vector": [1.5, -1.0, 1.6]}}} +{"insert": {"table" : "movies", "id" : 4, "doc" : {"title" : "Star Trek 4: Nemesis", "plot": "The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.", "_year": 2003, "rating": 6.0, "cat": "R", "code": [1,2,4], "type_vector": [0.4, 2.4, 0.9]}}} +"#; + + let res = index_api.bulk(bulk_body).await; + assert!(res.is_ok(), "Bulk insert failed: {:?}", res.err()); + + // Prepare search request + let query = SearchQuery { + query_string: Some(serde_json::json!("Star").into()), + ..Default::default() + }; + + let highlight = Highlight { + fields: Some(serde_json::json!(["title"]).into()), + ..Default::default() + }; + + let mut options = HashMap::new(); + options.insert("cutoff".to_string(), serde_json::json!(5)); + options.insert("ranker".to_string(), serde_json::json!("bm25")); + + let search_request = SearchRequest { + table: "movies".to_string(), + query: Some(Box::new(query)), + highlight: Some(Box::new(highlight)), + options: Some(serde_json::json!(options)), + ..Default::default() + }; + + // Perform search + let res = search_api.search(search_request).await; + assert!(res.is_ok(), "Search failed: {:?}", res.err()); + + let result = res.unwrap(); + println!("Search result: {:?}", result); + +} + diff --git a/tests/utils_api.rs b/tests/utils_api.rs new file mode 100755 index 0000000..2abc99c --- /dev/null +++ b/tests/utils_api.rs @@ -0,0 +1,40 @@ +use std::sync::Arc; +use manticoresearch::{apis::configuration::Configuration, apis::UtilsApi, apis::UtilsApiClient, models::SqlResponse}; + +use tokio; + + +#[tokio::test] +async fn utils_api_basic_requests() { + let api_config = Arc::new(Configuration::new()); + let utils_api = UtilsApiClient::new(api_config); + + // DROP TABLE IF EXISTS + let res = utils_api.sql("DROP TABLE IF EXISTS products", Some(true)).await; + assert!(res.is_ok(), "DROP TABLE failed: {:?}", res.err()); + + // CREATE TABLE + let create_query = "CREATE TABLE IF NOT EXISTS products (title text, price float, sizes multi, meta json, coeff float, tags1 multi, tags2 multi)"; + let res = utils_api.sql(create_query, Some(true)).await; + assert!(res.is_ok(), "CREATE TABLE failed: {:?}", res.err()); + + // SELECT with parse=true + let res = utils_api.sql("SELECT * FROM products", Some(true)).await; + assert!(res.is_ok(), "SELECT (parse=true) failed: {:?}", res.err()); + + // SELECT with parse=false + let res = utils_api.sql("SELECT * FROM products", Some(false)).await; + assert!(res.is_ok(), "SELECT (parse=false) failed: {:?}", res.err()); + + // SHOW TABLES + let res = utils_api.sql("SHOW TABLES", Some(true)).await; + assert!(res.is_ok(), "SHOW TABLES failed: {:?}", res.err()); + + let result = res.unwrap(); + let is_arr_response = matches!(result, SqlResponse::one_of_0 { .. }); + assert!(is_arr_response == true); + + if let SqlResponse::one_of_0(objs) = result { + println!("value: {:#?}", objs[0]); + } +}