コード例 #1
0
        /**
         * Replace new document in an index
         * Replace an existing document. Input has same format as `insert` operation. <br/> Responds with an object in format: <br/>    ```   {'_index':'products','_id':1,'created':false,'result':'updated','status':200}   ```
         * @param insertDocumentRequest  (required)
         * @return ApiResponse<SuccessResponse>
         * @throws ApiException if fails to make API call
         * @http.response.details
         * <table summary="Response Details" border="1">
         *   <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
         *   <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
         *   <tr><td> 0 </td><td> error </td><td>  -  </td></tr>
         * </table>
         *
         * @see <a href="https://docs.manticoresearch.com/latest/html/http_reference/json_insert.html">Replace new document in an index Documentation</a>
         */
        public ApiResponse <SuccessResponse> ReplaceWithHttpInfo(InsertDocumentRequest insertDocumentRequest)
        {
            object localVarPostBody = insertDocumentRequest;

            // verify the required parameter 'insertDocumentRequest' is set
            if (insertDocumentRequest == null)
            {
                throw new ApiException(400, "Missing the required parameter 'insertDocumentRequest' when calling replace");
            }

            // create path and Dictionary variables
            string localVarPath = "/json/replace";

            // query params
            List <Pair> localVarQueryParams = new List <Pair>();
            Dictionary <string, string> localVarHeaderParams = new Dictionary <string, string>();
            Dictionary <string, string> localVarCookieParams = new Dictionary <string, string>();
            Dictionary <string, object> localVarFormParams   = new Dictionary <string, object>();



            string[] localVarAccepts =
            {
                "application/json"
            };
            string localVarAccept = apiClient.SelectHeaderAccept(localVarAccepts);

            string[] localVarContentTypes =
            {
                "application/json"
            };
            string localVarContentType = apiClient.SelectHeaderContentType(localVarContentTypes);

            string[] localVarAuthNames = new string[] { };

            SuccessResponse localVarReturnType = new SuccessResponse()
            {
            };

            return(apiClient.InvokeAPI("IndexApi.replace", localVarPath, HttpMethod.Post, localVarQueryParams, localVarPostBody,
                                       localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
                                       localVarAuthNames, localVarReturnType, false));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            try
            {
                var util      = new UtilsApi();
                var searchApi = new SearchApi();
                var indexApi  = new IndexApi();

                Dictionary <string, object> result;
                try
                {
                    result = util.Sql(@"query=select * from products");
                    foreach (var item in result)
                    {
                        Console.WriteLine($"{item.Key} - {item.Value}");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

                var rs = util.Sql("mode=raw&query=create table products(title text, price float) morphology='stem_en'");

                Console.WriteLine("Create result " + rs.Count + Environment.NewLine);

                rs = util.Sql("mode=raw&query=SELECT * FROM products");

                Console.WriteLine("Select result " + rs.Count + Environment.NewLine);

                var newdoc = new InsertDocumentRequest();
                Dictionary <string, object> doc = new Dictionary <string, object>();
                doc.Add("title", "Crossbody Bag with Tassel");
                doc.Add("price", 19.85);

                newdoc.Index("products").Id(0).SetDoc(doc);
                var insertResult = indexApi.Insert(newdoc);

                Console.WriteLine(insertResult + Environment.NewLine);

                newdoc = new InsertDocumentRequest();
                doc    = new Dictionary <string, object>();

                doc.Add("title", "microfiber sheet set");
                doc.Add("price", 19.99);
                newdoc.Index("products").Id(0).SetDoc(doc);
                insertResult = indexApi.Insert(newdoc);

                Console.WriteLine(insertResult + Environment.NewLine);

                newdoc = new InsertDocumentRequest();
                doc    = new Dictionary <string, object>();
                doc.Add("title", "Pet Hair Remover Glove");
                doc.Add("price", 7.99);
                newdoc.Index("products").Id(0L).SetDoc(doc);
                insertResult = indexApi.Insert(newdoc);

                Console.WriteLine(insertResult + Environment.NewLine);

                var query = new Dictionary <string, object>();
                var match = new Dictionary <string, object>()
                {
                    { "title", "crossbody" }
                };
                query.Add("match", match);
                var searchRequest = new SearchRequest();
                searchRequest.SetIndex("products");
                searchRequest.SetQuery(query);
                Dictionary <string, object> highlight = new Dictionary <string, object>();
                highlight.Add("fields", new string[] { "title" });
                searchRequest.SetHighlight(highlight);
                var searchResponse = searchApi.Search(searchRequest);

                Console.WriteLine(searchResponse + Environment.NewLine);

                UpdateDocumentRequest updateRequest = new UpdateDocumentRequest();
                doc = new Dictionary <string, object>();
                doc.Add("price", 17.5);
                updateRequest.Index("products").Id(2L).SetDoc(doc);
                var updResult = indexApi.Update(updateRequest);

                Console.WriteLine(updResult + Environment.NewLine);

                DeleteDocumentRequest deleteRequest = new DeleteDocumentRequest();
                var condition = new Dictionary <string, object>()
                {
                    { "lte", 10 }
                };
                var field = new Dictionary <string, object>()
                {
                    { "price", condition }
                };
                query = new Dictionary <string, object>()
                {
                    { "range", field }
                };

                deleteRequest.Index("products").SetQuery(query);
                var deleteResult = indexApi.Delete(deleteRequest);

                Console.WriteLine(deleteResult + Environment.NewLine);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #3
0
 /**
  * Replace new document in an index
  * Replace an existing document. Input has same format as &#x60;insert&#x60; operation. &lt;br/&gt; Responds with an object in format: &lt;br/&gt;    &#x60;&#x60;&#x60;   {&#39;_index&#39;:&#39;products&#39;,&#39;_id&#39;:1,&#39;created&#39;:false,&#39;result&#39;:&#39;updated&#39;,&#39;status&#39;:200}   &#x60;&#x60;&#x60;
  * @param insertDocumentRequest  (required)
  * @return SuccessResponse
  * @throws ApiException if fails to make API call
  * @http.response.details
  * <table summary="Response Details" border="1">
  *   <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
  *   <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
  *   <tr><td> 0 </td><td> error </td><td>  -  </td></tr>
  * </table>
  *
  * @see <a href="https://docs.manticoresearch.com/latest/html/http_reference/json_insert.html">Replace new document in an index Documentation</a>
  */
 public SuccessResponse Replace(InsertDocumentRequest InsertDocumentRequest)
 {
     return(ReplaceWithHttpInfo(InsertDocumentRequest).GetData());
 }
コード例 #4
0
 /**
  * Create a new document in an index
  * Insert a document.  Expects an object like:     &#x60;&#x60;&#x60;   {&#39;index&#39;:&#39;movies&#39;,&#39;id&#39;:701,&#39;doc&#39;:{&#39;title&#39;:&#39;This is an old movie&#39;,&#39;plot&#39;:&#39;A secret team goes to North Pole&#39;,&#39;year&#39;:1950,&#39;rating&#39;:9.5,&#39;lat&#39;:60.4,&#39;lon&#39;:51.99,&#39;advise&#39;:&#39;PG-13&#39;,&#39;meta&#39;:&#39;{\&quot;keywords\&quot;:{\&quot;travel\&quot;,\&quot;ice\&quot;},\&quot;genre\&quot;:{\&quot;adventure\&quot;}}&#39;,&#39;language&#39;:[2,3]}}   &#x60;&#x60;&#x60;   The document id can also be missing, in which case an autogenerated one will be used:             &#x60;&#x60;&#x60;   {&#39;index&#39;:&#39;movies&#39;,&#39;doc&#39;:{&#39;title&#39;:&#39;This is a new movie&#39;,&#39;plot&#39;:&#39;A secret team goes to North Pole&#39;,&#39;year&#39;:2020,&#39;rating&#39;:9.5,&#39;lat&#39;:60.4,&#39;lon&#39;:51.99,&#39;advise&#39;:&#39;PG-13&#39;,&#39;meta&#39;:&#39;{\&quot;keywords\&quot;:{\&quot;travel\&quot;,\&quot;ice\&quot;},\&quot;genre\&quot;:{\&quot;adventure\&quot;}}&#39;,&#39;language&#39;:[2,3]}}   &#x60;&#x60;&#x60;   It responds with an object in format:      &#x60;&#x60;&#x60;   {&#39;_index&#39;:&#39;products&#39;,&#39;_id&#39;:701,&#39;created&#39;:true,&#39;result&#39;:&#39;created&#39;,&#39;status&#39;:201}   &#x60;&#x60;&#x60;
  * @param insertDocumentRequest  (required)
  * @return SuccessResponse
  * @throws ApiException if fails to make API call
  * @http.response.details
  * <table summary="Response Details" border="1">
  *   <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
  *   <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
  *   <tr><td> 0 </td><td> error </td><td>  -  </td></tr>
  * </table>
  *
  * @see <a href="https://docs.manticoresearch.com/latest/html/http_reference/json_insert.html">Create a new document in an index Documentation</a>
  */
 public SuccessResponse Insert(InsertDocumentRequest insertDocumentRequest)
 {
     return(InsertWithHttpInfo(insertDocumentRequest).GetData());
 }