Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerable<string> is treated as a wildcard search #431

Open
zulander1 opened this issue Jan 18, 2024 · 1 comment
Open

Enumerable<string> is treated as a wildcard search #431

zulander1 opened this issue Jan 18, 2024 · 1 comment

Comments

@zulander1
Copy link
Contributor

I am not sure if this is intentional or not but when we execute this code, this generates"FT.SEARCH" "customer:idx" "(@LastName:{*No*})" "LIMIT" "0" "100" caused by this

I think we should add valueType == typeof(IEnumerable<string>) check here

Making to ToList() works fine as expected

using Redis.OM;
using Redis.OM.Modeling;

var provider = new RedisConnectionProvider("redis://localhost:6379");
provider.Connection.CreateIndex(typeof(CustomerModel));
var customers = provider.RedisCollection<CustomerModel>();

// Insert customer
customers.Insert(new CustomerModel()
{
    Id = 1,
    FirstName = "James",
    LastName = "Bond",
}, WhenKey.NotExists);

customers.Insert(new CustomerModel()
{
    Id = 2,
    FirstName = "Dr",
    LastName = "No",
}, WhenKey.NotExists);
var agents = (new[] { "No" }).AsEnumerable();
var materialized = customers.Where(f => agents.Contains(f.LastName)).ToList();
Console.WriteLine("");

[Document(StorageType = StorageType.Json, Prefixes = new[] { Prefix }, IndexName = Prefix + ":idx")]
public class CustomerModel
{
    public const string Prefix = "customer";

    [Indexed][RedisIdField] public int Id { get; set; }
    [Indexed] public string FirstName { get; set; }
    [Indexed] public string LastName { get; set; }
}
 
@zulander1
Copy link
Contributor Author

Wouldn't it be easier just to inverse the logic and replace these two line with this:

if (attribute is IndexedAttribute)
{
    if (valueType == typeof(string) && type == typeof(string))
    {
        return $"({memberName}:{{*{EscapeTagField(literal)}*}})";
    }

    return $"({memberName}:{{{EscapeTagField(literal).Replace("\\|", "|")}}})";
}

@slorello89, can't seem to clone the repo:
Git failed with a fatal error.

src/Redis.OM.Vectorizers.AllMiniLML6V2/Resources/model.onnx: smudge filter lfs failed

Clone succeeded, but checkout failed.

You can inspect what was checked out with 'git status'

and retry with 'git restore --source=HEAD :/'

@slorello89 slorello89 changed the title Enumerable<string> is threated as a wildcard search Enumerable<string> is treated as a wildcard search Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant