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

Q: is possible to fetch the whole document by Id? #86

Closed
tiago-soczek opened this issue Dec 14, 2023 · 2 comments
Closed

Q: is possible to fetch the whole document by Id? #86

tiago-soczek opened this issue Dec 14, 2023 · 2 comments

Comments

@tiago-soczek
Copy link

Hello!

Is it possible to obtain the complete document by ID? When getting the results, I would like to have all the fields and values in the document, not just the ones that matched (FieldMatches).

@mikegoatly
Copy link
Owner

Hi @tiago-soczek!

There's nothing built in - there's a general expectation that you'll still be able to query the original source text/object that was used to construct the index.

For example, when you're extracting matched phrases from search results, you're required to pass a delegate that returns the original:

foreach (var result in await results.CreateMatchPhrasesAsync(i => books.First(x => x.BookId == i)))
{
    Console.WriteLine($"{result.SearchResult.Key} ({result.SearchResult.Score})");

    foreach (var fieldPhrase in result.FieldPhrases)
    {
        Console.Write($"  {fieldPhrase.FoundIn}: ");
        Console.WriteLine(string.Join(", ", fieldPhrase.Phrases.Select(x => $"\"{x}\"")));
    }
}

One of the objectives of indexing like this is to reduce the overall memory requirements of searching across all the items - storing the the original in memory would defeat that.

@tiago-soczek
Copy link
Author

Thanks @mikegoatly, got it! I'll change my implementation here!

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

2 participants