Permalink
Browse files

send 'not a valid view' only if the view is not defined (resolves #7).

  • Loading branch information...
1 parent 71cbc0b commit 56acf28a0979d062f5303a24cff1af109902ffbe Robert Newson committed Aug 3, 2009
Showing with 1 addition and 22 deletions.
  1. +1 −22 src/main/java/com/github/rnewson/couchdb/lucene/Search.java
@@ -39,7 +39,6 @@
public final class Search {
private static final Progress progress = new Progress();
- private static final Set<String> validViews = new HashSet<String>();
public static void main(final String[] args) {
Utils.LOG.info("searcher started.");
@@ -116,7 +115,7 @@ public static void main(final String[] args) {
final String viewname = Utils.viewname(path);
- if (!validViews.contains(viewname)) {
+ if (progress.getSeq(viewname) == 0) {
Utils.out(Utils.error(400, viewname + " is not a valid view."));
}
@@ -177,27 +176,7 @@ private static long size(final Directory dir) throws IOException {
return result;
}
- private static void getValidViews(final IndexReader reader, final Set<String> out) throws IOException {
- out.clear();
- final TermEnum terms = reader.terms(new Term(Config.VIEW));
- try {
- do {
- final Term term = terms.term();
- if (term == null || !Config.VIEW.equals(term.field())) {
- break;
- }
- out.add(term.text());
- } while (terms.next());
- } finally {
- terms.close();
- }
- }
-
private static void onNewReader(final IndexReader reader) throws IOException {
- // Remember list of valid views.
- getValidViews(reader, validViews);
-
- // Remember signatures of views.
progress.load(reader);
}

0 comments on commit 56acf28

Please sign in to comment.