Beispiel #1
0
        public async Task DeleteAsync <T>(T item, IGraphRequestContext graphRequestContext) where T : class
        {
            var client = Get <T>(graphRequestContext);

            var batch = IndexDocumentsBatch.Create(IndexDocumentsAction.Delete(item));
            await client.IndexDocumentsAsync(batch);
        }
        public void DeleteCustomerData(CustomerIndex customerToDelete)
        {
            IndexDocumentsBatch <CustomerIndex> batch = IndexDocumentsBatch.Create(IndexDocumentsAction.Delete(customerToDelete));
            IndexDocumentsOptions idxoptions          = new IndexDocumentsOptions {
                ThrowOnAnyError = true
            };

            _qryClient.IndexDocuments(batch, idxoptions);
        }
Beispiel #3
0
        public async Task Convenience_None()
        {
            await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync <SimpleDocument>(this);

            SearchClient client = resources.GetSearchClient();

            SimpleDocument[] data = SimpleDocument.GetDocuments(3);

            await using SearchIndexingBufferedSender <SimpleDocument> indexer =
                            client.CreateIndexingBufferedSender(
                                new SearchIndexingBufferedSenderOptions <SimpleDocument>());
            AssertNoFailures(indexer);
            IndexDocumentsBatch <SimpleDocument> batch = IndexDocumentsBatch.Create(
                IndexDocumentsAction.Delete <SimpleDocument>(data[0]),
                IndexDocumentsAction.Upload <SimpleDocument>(data[1]),
                IndexDocumentsAction.MergeOrUpload <SimpleDocument>(data[2]));
            await indexer.IndexDocumentsAsync(batch);

            await indexer.FlushAsync();

            await WaitForDocumentCountAsync(resources.GetSearchClient(), 2);
        }
Beispiel #4
0
        /// <summary>
        /// Añade o elimina items dentro de azure search.
        /// </summary>
        /// <typeparam name="T">El tipo solo puede ser una entidad soportada dentro de azure search, se validará que cumpla</typeparam>
        /// <param name="elements">elementos a guardar dentro del search</param>
        /// <param name="operationType">Tipo de operación Añadir o borrar</param>
        private void OperationElements <T>(List <T> elements, SearchOperation operationType)
        {
            // validar que sea un elemento de tipo search.
            var indexName = Index;

            // realiza la acción segun el argumento
            var actions = elements.Select(o => operationType == SearchOperation.Add ? IndexDocumentsAction.Upload(o) : IndexDocumentsAction.Delete(o)).ToArray();

            // preparando la ejecución
            var batch = IndexDocumentsBatch.Create(actions);

            // ejecución.
            _search.IndexDocuments(batch);
        }
Beispiel #5
0
 private static void DeleteEntry(DeleteIndexEntry delete, IList <IndexDocumentsAction <SearchDocument> > batch)
 {
     batch.Add(IndexDocumentsAction.Delete("docId", delete.DocId.ToBase64()));
 }