/// <summary> /// Builds a Bulk JSON that allows to remove custom Json document from specified Index. /// If no index and type parameters specified, they will be taken from BulkCommand parameters. /// </summary> /// <param name="index">The ES index name, if not specified will be taken from BulkCommand endpoint address.</param> /// <param name="type">The ES type name, if not specified will be taken from BulkCommand endpoint address.</param> /// <param name="id">The Id of document to remove from ES index.</param> /// <param name="options">The bulk operation options.</param> /// <param name="customOptions">The custom JSON options for create operation. /// Options should be comma separated string of values: /// <c>"_index": "test", "_type": "first", "_id": 1, "_version": 100</c> /// </param> public string Delete(string id, string index = null, string type = null, BulkOperationOptions options = null, string customOptions = null) { string optionsJson = options == null ? "" : options.ToString(); var parameters = BuildOperationParameters(index, type, id, optionsJson, customOptions); var command = "{{ 'delete': {{ {0} }} }}\n".AltQuoteF(parameters); return(command); }
/// <summary> /// Builds a Bulk JSON that allows to add or update custom Json document in specified Index. /// If no index and type parameters specified, they will be taken from BulkCommand parameters. /// </summary> /// <param name="data">The document to add or update in ES index.</param> /// <param name="index">The ES index name, if not specified will be taken from BulkCommand endpoint address.</param> /// <param name="type">The ES type name, if not specified will be taken from BulkCommand endpoint address.</param> /// <param name="id">The document id, if not specified will be generated automatically by ES (This will add new document).</param> /// <param name="options">The bulk operation options.</param> /// <param name="customOptions">The custom JSON options for create operation. /// Options should be comma separated string of values: /// <c>"_index": "test", "_type": "first", "_id": 1, "_version": 100</c> /// </param> public string Index(object data, string index = null, string type = null, string id = null, BulkOperationOptions options = null, string customOptions = null) { string optionsJson = options == null ? "" : options.ToString(); var parameters = BuildOperationParameters(index, type, id, optionsJson, customOptions); var command = "{{ 'index': {{ {0} }} }}\n".AltQuoteF(parameters); var dataJson = serializer.Serialize(data) + "\n"; return(command + dataJson); }