Skip to content

Exception while executing search #536

Open
@mfaulcon-mynexus

Description

@mfaulcon-mynexus

I have a CachedUser class (defined below) for which I'm trying to execute a string.contains query on one of the member fields, during which I'm getting an exception. I've listed the code and runtime values below. If I perform straight equality searches, it appears to work correctly.

CachedUser.cs

[Document(StorageType = StorageType.Json, Prefixes = [Prefix], IndexName = Prefix + ":idx")]
public class CachedUser : IEntity<Guid>
{
    public const string Prefix = "graph3:user";

    [Indexed(Sortable = true, IndexEmptyAndMissing = false)]
    [RedisIdField]
    public Guid UserId { get; set; }

    [Indexed(IndexEmptyAndMissing = false)]
    public string? Email { get; set; }

    [Indexed(Sortable = true, IndexEmptyAndMissing = false)]
    public string? FirstName { get; set; }

    [Searchable(Sortable = true, IndexEmptyAndMissing = false)]
    public string? LastName { get; set; }

    [Indexed(Sortable = true, IndexEmptyAndMissing = false)]
    public string? DisplayName { get; set; }

    [Indexed(IndexEmptyAndMissing = false)]
    public string? Credentials { get; set; }

    // Irrelevant properties removed

    [JsonIgnore]
    public Guid Id => UserId;
}

The Index being created (formatted for readability):

FT.CREATE graph3:user:idx ON Json PREFIX 1 graph3:user SCHEMA 
  $.UserId AS UserId TAG SEPARATOR | SORTABLE
  $.Email AS Email TAG SEPARATOR |
  $.FirstName AS FirstName TAG SEPARATOR | SORTABLE
  $.LastName AS LastName TEXT SORTABLE
  $.DisplayName AS DisplayName TAG SEPARATOR | SORTABLE
  $.Credentials AS Credentials TAG SEPARATOR |

The expression being executed at runtime:

.Where(u => u.contains("Fal"))
.Select(cu => new CachedUser()
{
  UserId = cu.UserId,
  Email = cu.Email,
  FirstName = cu.FirstName,
  LastName = cu.LastName,
  DisplayName = cu.DisplayName
})
.Take(11);

The Redis search the expression is being translated to:

FT.SEARCH graph3:user:idx ((ismissing(@LastName)) (@LastName:Fal)) DIALECT 2 LIMIT 0 11 RETURN 21 UserId AS UserId Email AS Email FirstName AS FirstName LastName AS LastName DisplayName AS DisplayName

The exception being thrown:

StackExchange.Redis.RedisServerException:Syntax error at offset 21 near LastName
   at Redis.OM.RedisConnection.ExecuteAsync(String command, Object[] args) in \Redis.OM\src\Redis.OM\RedisConnection.cs:line 45

When I execute the same command from the CLI, I get the error: "Unknown argument (@LastName:Fal)) at position 2 for

"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions