redis-om-dotnet
redis-om-dotnet copied to clipboard
Contains only searches inside string[] & List<string>() NOT HashSet<string>()
Hello @slorello89
Looking at the following example:
[Document(StorageType = StorageType.Json)]
public class Customer
{
[RedisIdField] public Ulid Id { get; set; }
[Indexed] public string FirstName { get; set; }
[Indexed] public string LastName { get; set; }
public string Email { get; set; }
[Indexed(Sortable = true)] public int Age { get; set; }
[Indexed] public string[] NickNames { get; set; }
}
// Find all customers with the nickname of Jim
customer.Where(x=>x.NickNames.Contains("Jim"));
This only works if the underlying type is string[]. Can we add List
UPDATE: Tested and working with both List
Once I reindex as Hashset, I lost functionality.
Once I reindex as List
So since it looks like I can get data back with my model as HashSet
Have you confirmed that the index has those list and hashset fields defined in it?
I spent hours the other days trying to figure out why the search didn't work and turn out I had to delete and recreate the index to reflect the change from the ORM.
Have you confirmed that the index has those list and hashset fields defined in it?
I spent hours the other days trying to figure out why the search didn't work and turn out I had to delete and recreate the index to reflect the change from the ORM.
Yeah. I was getting no results back using HashSet<string>
and once I changed only the model to be string[]
then I got results back.
Right, so List
Right, so List and string[] should both work, only reason I'd think to keep a hash-set out is that the data-type in Redis is not going to be a set, it's a going to be a JSON array, so the unordered/non-duplication policies of a hash-set will not be enforceable.
@slorello89 Except that they will be enforced once the model is loaded and if it's resaved, any duplicates are automatically removed. Which is the effect I was going for. I think it should be indexed in addition to the string[]
and List<string>
.