NRediSearch icon indicating copy to clipboard operation
NRediSearch copied to clipboard

no batch processing for redis search

Open kishoretvk opened this issue 6 years ago • 3 comments

kishoretvk avatar Jun 30 '19 00:06 kishoretvk

there is no support for redis search batch add hashes, we have to call the add function in async. which is not super fast, for adding a million or 10 million records

kishoretvk avatar Jun 30 '19 00:06 kishoretvk

can you be more specific? is there a particular command you would have this execute? note that NRediSearch was a port of JRediSearch - is there a JRediSearch API this should mimic? Basically: what would you have this do, in terms of redis behavior?

mgravell avatar Jun 30 '19 07:06 mgravell

Thanks for responding, here are some more details. in normal redis client we create a batch for hashes or sets and push them all at once. example code

var redis = RedisStore.RedisCache;          
            
            RedisKey alphaKey = "alphaKey";
            RedisKey betaKey = "betaKey";
 
            //Batching
            var list = new List<Task<bool>>();
            var keys = new List<RedisKey> {alphaKey, betaKey};
            IBatch batch = redis.CreateBatch();
 
            //add the delete into batch
            batch.KeyDeleteAsync(alphaKey);
 
            foreach (var key in keys)
            {
                var task = batch.StringSetAsync(key, "123");
                list.Add(task);
            }
 
            batch.Execute();
 
            Task.WhenAll(list.ToArray());
 

however in NredisSearch, we do not see such batch, we create an index

var index = "TestIndex";
var tasks = new  List<Task<bool>>();
var clientsearch = new Client(index, rediscache);
foreach(hashdata in hashresults)
{
var dataresult = clientsearch addhashasync(hashdata .id, hashdata.data , nosave);
taks.add(dataresult);
}
Tasks.Whenall(tasks.ToArray());

is there a way in which we can add batch support here as well?

kishoretvk avatar Jul 02 '19 03:07 kishoretvk