Repository navigation
Answer queries on an index with no documents - #106
Open
danielgreen wants to merge 2 commits into
Open
danielgreen wants to merge 2 commits into
danielgreen wants to merge 2 commits into
Conversation
Searching, counting or fetching a document from an index that had no documents written yet failed with a 500 (DirectoryNotFoundException), because the Lucene directory does not exist until the first write. Azure answers with an empty result, a count of 0 and a 404 for the key. When the directory holds no Lucene index, the reader factory now returns an empty reader. It is not cached, so the first write is seen by the next read. This also covers indexes created before this change. The unexpected-failure integration test relied on that 500, so it now uses a full Lucene query that does not parse.
Member
|
Thanks for all the PRs, I'll be looking at getting these merged very soon! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #105
An index that has had no documents written has no Lucene directory yet. Opening a reader on it threw
DirectoryNotFoundException, so search, get-by-key, suggest and autocomplete answered 500. Azure answers an empty result (and 404 for a missing key).The reader factory now checks
DirectoryReader.IndexExistsand, if there is no Lucene index, returns an empty reader. The empty reader is not cached, and indexing already refreshes the cached reader after each commit, so the first write is visible to the next read. The check is on the read side, so indexes created before this change also work.Tests:
EmptyIndexTestsuse the real reader factory over an on-disk directory that does not exist (an in-memory directory would pass without the fix). They cover search, count, get-by-key, suggest, autocomplete, a folder that exists but is empty, and a search that finds a document uploaded after an empty read.ErrorResponseIntegrationTests.UnexpectedFailure_ReturnsEnvelopeWithoutInternalDetailrelied on the old 500. It now uses an unparseable full Lucene query (search=(&queryType=full), which still answers 500. That is a separate gap, since Azure answers 400.DebugClienthas a new check that searches an empty index.I can file the malformed full-syntax query 500 (Azure answers 400) as a separate issue if you want.