Skip to content

Commit

Permalink
Merge pull request #5087 from apache/minseqmore
Browse files Browse the repository at this point in the history
Use the minSeq check in more places and add a test
  • Loading branch information
rnewson committed Jun 13, 2024
2 parents 64bf1de + 1c6e836 commit f9afe9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected Result check() throws Exception {

final SearchRequest searchRequest = new SearchRequest();
searchRequest.setQuery("_id:foo");
searchRequest.setMinUpdateSeq(1);

final SearchResults searchResults = indexResource.searchIndex(name, searchRequest);
if (searchResults.getTotalHits() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.couchdb.nouveau.api.SearchResults;
import org.apache.couchdb.nouveau.api.StringField;
import org.apache.couchdb.nouveau.core.Index;
import org.apache.couchdb.nouveau.core.StaleIndexException;
import org.apache.couchdb.nouveau.core.UpdatesOutOfOrderException;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.IndexWriter;
Expand Down Expand Up @@ -80,6 +81,7 @@ public void testSearching(@TempDir Path path) throws IOException {
index.update("doc" + i, request);
}
final SearchRequest request = new SearchRequest();
request.setMinUpdateSeq(count);
request.setQuery("*:*");
final SearchResults results = index.search(request);
assertThat(results.getTotalHits()).isEqualTo(count);
Expand All @@ -99,6 +101,7 @@ public void testSort(@TempDir Path path) throws IOException {
index.update("doc" + i, request);
}
final SearchRequest request = new SearchRequest();
request.setMinUpdateSeq(count);
request.setQuery("*:*");
request.setSort(List.of("foo"));
final SearchResults results = index.search(request);
Expand All @@ -119,6 +122,7 @@ public void testCounts(@TempDir Path path) throws IOException {
index.update("doc" + i, request);
}
final SearchRequest request = new SearchRequest();
request.setMinUpdateSeq(count);
request.setQuery("*:*");
request.setCounts(List.of("bar"));
final SearchResults results = index.search(request);
Expand All @@ -139,6 +143,7 @@ public void testRanges(@TempDir Path path) throws IOException {
index.update("doc" + i, request);
}
final SearchRequest request = new SearchRequest();
request.setMinUpdateSeq(count);
request.setQuery("*:*");
request.setRanges(Map.of(
"bar",
Expand Down Expand Up @@ -175,6 +180,22 @@ public void testOutOfOrder(@TempDir Path path) throws IOException {
}
}

@Test
public void testMinSeq(@TempDir Path path) throws IOException {
Index index = setup(path);
try {
// Require min seq 1 on new, empty index should fail.
assertThrows(StaleIndexException.class, () -> {
final SearchRequest request = new SearchRequest();
request.setMinUpdateSeq(1);
request.setQuery("*:*");
index.search(request);
});
} finally {
cleanup(index);
}
}

@Test
public void testInfo(@TempDir Path path) throws IOException {
Index index = setup(path);
Expand Down

0 comments on commit f9afe9f

Please sign in to comment.