redis / redis-om-dotnet

Object mapping, and more, for Redis and .NET
MIT License
467 stars 79 forks source link

Support [Index] and [Searchable] on the same property #244

Open VagyokC4 opened 2 years ago

VagyokC4 commented 2 years ago

Hi @slorello89,

There are times I need to do an exact match AND times I want to search match on a model property.

As a temp work-around I've resorted to doubling the data in the model via

    [Document(StorageType = StorageType.Json)]
    public record IndexedSearchableRecord
    {
        [Searchable] public string NameSearch => Name;
        [Indexed]    public string Name       { get; set; }
    }

Not sure what it would look like but would love the ability to index both types on a single property and be able to search either indexed.equals/contains or searchable.contains.

Thoughts?

slorello89 commented 2 years ago

This would be nice to have, there's nothing inherently wrong with indexing the same path twice. Inherently I think that your probably right - having contains operate on the text index and equals operate on the tag index seems like it's probably a sensible compromise here.

VagyokC4 commented 2 years ago

This would be nice to have, there's nothing inherently wrong with indexing the same path twice. Inherently I think that your probably right - having contains operate on the text index and equals operate on the tag index seems like it's probably a sensible compromise here.

So I think we still need a contains for the tag side when it's an array[] property, or do you mean that would look like an == operation as well (similar to the Flag Enum)