Skip to content

IndexOutOfRangeException: Index was outside the bounds of the array. at NRedisStack.Search.Document.Load #352

@ruwentos

Description

@ruwentos

NRedisStack Version: 0.13.0

Redis Stack Version: 2.8.16

Description: We got an 'Index was outside the bounds of the array' exception at NRedisStack.Search.Document.Load. This happend while we searched Redis with a query through SearchCommandsAsync.SearchAsync(string indexName, Query q).

I can test the static function NRedisStack.Search.Document.Load and will get this exception every time the parameter RedisValue[]? fields contains an uneven count of items.
So first I thought this would be a flaw in your code. But then I wrote a test that mimics the situation where the exception occurred and I'm not able to reproduce this exception.
What I see is that your code depends on what comes out of await _db.ExecuteAsync(SearchCommandBuilder.Search(indexName, q)) in your SearchCommandsAsync function:

public async Task<SearchResult> SearchAsync(string indexName, Query q)
{
    if (q.dialect == null && defaultDialect != null)
    {
        q.Dialect((int)defaultDialect);
    }

    return (await _db.ExecuteAsync(SearchCommandBuilder.Search(indexName, q))).ToSearchResult(q);
}

My questions:

  1. Have you ever experienced/heard about that the RedisResult object was shaped so that your code through an exception?
  2. Can you think of a cause of this?
  3. Do you consider to change your code that it could handle the situation without an exception?

kind regards

Swen

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