Reputation: 97
I have a .net core microservice integrated with Redis/RediSearch. I do a search that should return 13 hash documents but returns only 10. In elasticSearch there is a default size parameter(10) but in Redis I didn't find similar. How can I solve ?
public List<DynamicDoc> GetFullMoc(string queryParm){
var redisConection = ConnectionMultiplexer.Connect(GetParameter("REDIS_SERVER"));
var dbRedis = new Client("feeders", redisConection.GetDatabase());
string searchString = "@MOC:" + queryParm;
NRediSearch.Query query = new NRediSearch.Query(searchString);
string[] returnFields = { "Moc", "H_W","H_Y", "F"};
query.ReturnFields(returnFields);
query.WithPayloads = true;
SearchResult res = dbRedis.Search(query);
List<DynamicDoc> dynamicDocs = new List<DynamicDoc>();
foreach (Document doc in res.Documents)
{
IEnumerable<KeyValuePair<string, RedisValue>> record = doc.GetProperties();
string jsonRecord = JsonConvert.SerializeObject(record);
Dictionary<string, object> _record = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonRecord);
Console.WriteLine("\n \n \n ================" + doc.Id + "================ \n \n \n");
foreach(var rec in _record){
Console.WriteLine(rec);
}
DynamicDoc dynamicDoc = new DynamicDoc()
{
id = doc.Id,
score = doc.Score,
payload = _record
};
dynamicDocs.Add(dynamicDoc);
}
return dynamicDocs;
}
DynamicDoc:
namespace cached_data_manager.Business.Interface
{
public class DynamicDoc
{
public string id { get; set; }
public double score { get; set; }
public Dictionary<string, object> payload{ get; set; }
}
}
Upvotes: 2
Views: 3635
Reputation: 6267
FT.SEARCH
command has a optional LIMIT
parameter which takes two arguments, offset
and num
. The default values are 0 and 10 respectively.
From the command description:
LIMIT first num : Limit the results to the offset and number of results given. Note that the offset is zero-indexed. The default is 0 10, which returns 10 items starting from the first result.
Here is the complete command description: https://oss.redis.com/redisearch/Commands/#ftsearch
To do it programmatically, use the Limit
option in NRediSearch.Query. E.g.
query.Limit(0, 10000);
Upvotes: 4