Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove registry and indexkey, change output paths

  • Loading branch information...
commit cbfe065625996b5ba26f7834a4a10f3f097dbca9 1 parent 78b4430
@rnewson authored
View
19 README.md
@@ -39,20 +39,25 @@ You will now have a zip file in the target/ directory. This contains all the cou
os_process_timeout=60000 ; increase the timeout from 5 seconds.
[external]
-fti=/path/to/python /usr/lib/couchdb/couchdb-lucene/couchdb-external-hook.py --host=localhost --port=5985
+fti=/path/to/python /usr/lib/couchdb/couchdb-lucene/couchdb-external-hook.py
[httpd_db_handlers]
_fti = {couch_httpd_external, handle_external_req, <<"fti">>}
</pre>
-<h1>Configure couchdb-lucene</h1>
+<h2>Hook options</h2>
+
+<table>
+<tr><th>Option</th><th>Meaning</th><th>Default Value</th></tr>
+<tr><td>--remote-host</td><td>The hostname of the couchdb-lucene server</td><td>localhost</td></tr>
+<tr><td>--remote-port</td><td>The port of the couchdb-lucene server</td><td>5985</td></tr>
+<tr><td>--local-host</td><td>The hostname of the couchdb server</td><td>localhost</td></tr>
+<tr><td>--local-port</td><td>The port of the couchdb server</td><td>5984</td></tr>
+</table>
-couchdb-lucene runs in a single, standalone JVM. As such, you can choose to locate your couchdb-lucene server on a different machine to couchdb if you wish, or keep it on the same machine, it's your call.
+<h1>Configure couchdb-lucene</h1>
-<ol>
-<li>Unzip the couchdb-lucene zip file.
-<li>Open the conf/couchdb-lucene.properties file.
-<li>Edit the couchdb.url to point to your couchdb installation.
+couchdb-lucene runs in a single, standalone JVM. As such, you can choose to locate your couchdb-lucene server on a different machine to couchdb if you wish, or keep it on the same machine, it's your call.
<h1>Start couchdb-lucene</h1>
View
27 couchdb-external-hook.py
@@ -15,15 +15,18 @@
def options():
return [
- op.make_option('--host', dest='host',
- default="127.0.0.1",
+ op.make_option('--remote-host', dest='remote_host',
+ default="localhost",
help="Hostname of the couchdb-lucene server. [%default]"),
- op.make_option('--port', dest='port', type='int',
+ op.make_option('--remote-port', dest='remote_port', type='int',
default=5985,
help="Port of the couchdb-lucene server. [%default]"),
- op.make_option('--key', dest='key',
- default="local",
- help="Host key of this couchdb instance. [%default]")
+ op.make_option('--local-host', dest='local_host',
+ default="localhost",
+ help="Hostname of this couchdb instance. [%default]"),
+ op.make_option('--local-port', dest='local_port', type='int',
+ default=5984,
+ help="Port of this couchdb instance. [%default]"),
]
def main():
@@ -32,14 +35,14 @@ def main():
if len(args):
parser.error("Unrecognized arguments: %s" % ' '.join(args))
- res = httplib.HTTPConnection(opts.host, opts.port)
+ res = httplib.HTTPConnection(opts.remote_host, opts.remote_port)
for req in requests():
try:
- resp = respond(res, req, opts.key)
+ resp = respond(res, req, opts.local_host, opts.local_port)
except Exception, e:
body = traceback.format_exc()
resp = mkresp(500, body, {"Content-Type": "text/plain"})
- res = httplib.HTTPConnection(opts.host, opts.port)
+ res = httplib.HTTPConnection(opts.remote_host, opts.remote_port)
sys.stdout.write(json.dumps(resp))
sys.stdout.write("\n")
@@ -51,18 +54,18 @@ def requests():
yield json.loads(line)
line = sys.stdin.readline()
-def respond(res, req, host_key):
+def respond(res, req, host, port):
path = req.get("path", [])
if len(path) != 4:
body = "\n".join([
"Invalid path: %s" % '/'.join([''] + path),
- "Paths should be: /host_key/db_name/_fti/docid/index_name?q=...",
+ "Paths should be: /db_name/_fti/docid/index_name?q=...",
"'docid' is from the '_design/docid' that defines index_name"
])
return mkresp(400, body, {"Content-Type": "text/plain"})
- path = '/'.join(['', 'search', host_key, path[0], path[2], path[3]])
+ path = '/'.join(['', 'search', host, str(port), path[0], path[2], path[3]])
path = '?'.join([path, urllib.urlencode(req["query"])])
req_headers = {}
View
3  src/main/conf/couchdb-lucene.properties
@@ -1,6 +1,3 @@
-# The location of CouchDB.
-couchdb.url.local=http://localhost:5984
-
# The output directory for Lucene indexes.
lucene.dir=indexes
View
6 src/main/java/com/github/rnewson/couchdb/lucene/AdminServlet.java
@@ -36,12 +36,10 @@ public void setLucene(final Lucene lucene) {
@Override
protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
- final IndexKey key = new IndexKey(req);
-
final String command = req.getParameter("cmd");
if ("expunge".equals(command)) {
- lucene.withWriter(key, new WriterCallback() {
+ lucene.withWriter(req.getPathInfo(), new WriterCallback() {
public boolean callback(final IndexWriter writer) throws IOException {
writer.expungeDeletes(false);
return false;
@@ -56,7 +54,7 @@ public void onMissing() throws IOException {
}
if ("optimize".equals(command)) {
- lucene.withWriter(key, new WriterCallback() {
+ lucene.withWriter(req.getPathInfo(), new WriterCallback() {
public boolean callback(final IndexWriter writer) throws IOException {
writer.optimize(false);
return false;
View
35 src/main/java/com/github/rnewson/couchdb/lucene/CouchDbRegistry.java
@@ -1,35 +0,0 @@
-package com.github.rnewson.couchdb.lucene;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.log4j.Logger;
-
-public final class CouchDbRegistry {
-
- private static final Logger LOG = Logger.getLogger(CouchDbRegistry.class);
-
- private final Map<String, String> hostMap = new HashMap<String, String>();
-
- public CouchDbRegistry(final Properties properties, final String prefix) {
- for (final String name : properties.stringPropertyNames()) {
- if (name.startsWith(prefix)) {
- mapHostKeyToUrl(name.substring(prefix.length()), properties.getProperty(name));
- }
- }
- LOG.info(hostMap);
- }
-
- public synchronized void mapHostKeyToUrl(final String key, final String url) {
- hostMap.put(key, url.endsWith("/") ? url : url + "/");
- }
-
- public synchronized String createUrlByHostKey(final String key, final String path) {
- final String url = hostMap.get(key);
- if (url == null)
- return null;
- return url + path;
- }
-
-}
View
104 src/main/java/com/github/rnewson/couchdb/lucene/IndexKey.java
@@ -1,104 +0,0 @@
-package com.github.rnewson.couchdb.lucene;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * An IndexKey uniquely identifies an index.
- *
- * @author robertnewson
- */
-public final class IndexKey {
-
- private final String databaseName;
- private final String designDocumentName;
- private final String hostKey;
- private final String viewName;
-
- public IndexKey(final HttpServletRequest req) {
- this(req.getPathInfo().substring(1).split("/"));
- }
-
- public IndexKey(final String hostKey, final String databaseName, final String designDocumentName, final String viewName) {
- this(new String[] { hostKey, databaseName, designDocumentName, viewName });
- }
-
- private IndexKey(final String... args) {
- if (args.length != 4) {
- throw new IllegalArgumentException();
- }
- for (final String str : args) {
- if (str == null) {
- throw new NullPointerException();
- }
- }
- this.hostKey = args[0];
- this.databaseName = args[1];
- this.designDocumentName = args[2];
- this.viewName = args[3];
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final IndexKey other = (IndexKey) obj;
- if (!databaseName.equals(other.databaseName)) {
- return false;
- } else if (!designDocumentName.equals(other.designDocumentName)) {
- return false;
- } else if (!hostKey.equals(other.hostKey)) {
- return false;
- } else if (!viewName.equals(other.viewName)) {
- return false;
- }
- return true;
- }
-
- public String getDatabaseName() {
- return databaseName;
- }
-
- public String getDesignDocumentName() {
- return designDocumentName;
- }
-
- public String getHostKey() {
- return hostKey;
- }
-
- public String getViewName() {
- return viewName;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + databaseName.hashCode();
- result = prime * result + designDocumentName.hashCode();
- result = prime * result + hostKey.hashCode();
- result = prime * result + viewName.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- final StringBuffer buffer = new StringBuffer(100);
- buffer.append(hostKey);
- buffer.append("/");
- buffer.append(databaseName);
- buffer.append("/");
- buffer.append(designDocumentName);
- buffer.append("/");
- buffer.append(viewName);
- return buffer.toString();
- }
-
-}
View
4 src/main/java/com/github/rnewson/couchdb/lucene/InfoServlet.java
@@ -44,9 +44,7 @@ public void setLucene(final Lucene lucene) {
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
- final IndexKey key = new IndexKey(req);
-
- lucene.withReader(key, Utils.getStaleOk(req), new ReaderCallback() {
+ lucene.withReader(req.getPathInfo(), Utils.getStaleOk(req), new ReaderCallback() {
public void callback(final IndexReader reader) throws IOException {
final JSONObject result = new JSONObject();
result.put("current", reader.isCurrent());
View
34 src/main/java/com/github/rnewson/couchdb/lucene/Lucene.java
@@ -22,9 +22,8 @@
public final class Lucene {
private final File root;
- private final CouchDbRegistry registry;
- private final IdempotentExecutor<IndexKey> executor = new IdempotentExecutor<IndexKey>();
- private final Map<IndexKey, Tuple> map = new HashMap<IndexKey, Tuple>();
+ private final IdempotentExecutor<String> executor = new IdempotentExecutor<String>();
+ private final Map<String, Tuple> map = new HashMap<String, Tuple>();
private static class Tuple {
private String version;
@@ -66,19 +65,18 @@ public void close() throws IOException {
public void onMissing() throws IOException;
}
- public Lucene(final File root, final CouchDbRegistry registry) {
+ public Lucene(final File root) {
this.root = root;
- this.registry = registry;
}
- public void startIndexing(final IndexKey indexKey) {
- executor.submit(indexKey, new ViewIndexer(this, registry, indexKey));
+ public void startIndexing(final String path) {
+ executor.submit(path, new ViewIndexer(this, path));
}
- public void withReader(final IndexKey key, final boolean staleOk, final ReaderCallback callback) throws IOException {
+ public void withReader(final String path, final boolean staleOk, final ReaderCallback callback) throws IOException {
final Tuple tuple;
synchronized (map) {
- tuple = map.get(key);
+ tuple = map.get(path);
}
if (tuple == null) {
callback.onMissing();
@@ -114,11 +112,11 @@ public void withReader(final IndexKey key, final boolean staleOk, final ReaderCa
}
}
- public void withSearcher(final IndexKey key, final boolean staleOk, final SearcherCallback callback) throws IOException {
- withReader(key, staleOk, new ReaderCallback() {
+ public void withSearcher(final String path, final boolean staleOk, final SearcherCallback callback) throws IOException {
+ withReader(path, staleOk, new ReaderCallback() {
public void callback(final IndexReader reader) throws IOException {
- callback.callback(new IndexSearcher(reader), map.get(key).version);
+ callback.callback(new IndexSearcher(reader), map.get(path).version);
}
public void onMissing() throws IOException {
@@ -127,10 +125,10 @@ public void onMissing() throws IOException {
});
}
- public void withWriter(final IndexKey key, final WriterCallback callback) throws IOException {
+ public void withWriter(final String path, final WriterCallback callback) throws IOException {
final Tuple tuple;
synchronized (map) {
- tuple = map.get(key);
+ tuple = map.get(path);
}
if (tuple == null) {
@@ -144,24 +142,24 @@ public void withWriter(final IndexKey key, final WriterCallback callback) throws
tuple.dirty = dirty;
}
} catch (final OutOfMemoryError e) {
- map.remove(key).writer.rollback();
+ map.remove(path).writer.rollback();
throw e;
}
}
- public void createWriter(final IndexKey key, final UUID uuid, final String function) throws IOException {
+ public void createWriter(final String path, final UUID uuid, final String function) throws IOException {
final String digest = digest(function);
final File dir = new File(new File(root, uuid.toString()), digest);
dir.mkdirs();
synchronized (map) {
- Tuple tuple = map.remove(key);
+ Tuple tuple = map.remove(path);
if (tuple != null) {
tuple.close();
}
final Directory d = FSDirectory.open(dir);
tuple = new Tuple(newWriter(d));
- map.put(key, tuple);
+ map.put(path, tuple);
}
}
View
3  src/main/java/com/github/rnewson/couchdb/lucene/Main.java
@@ -45,8 +45,7 @@ public static void main(String[] args) throws Exception {
}
LOG.info("Index output goes to: " + dir.getCanonicalPath());
- final CouchDbRegistry registry = new CouchDbRegistry(properties, "couchdb.url.");
- final Lucene lucene = new Lucene(dir, registry);
+ final Lucene lucene = new Lucene(dir);
final int port = Integer.parseInt(properties.getProperty("lucene.port", "5985"));
final Server jetty = jetty(lucene, port);
View
13 src/main/java/com/github/rnewson/couchdb/lucene/SearchServlet.java
@@ -305,14 +305,7 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
final boolean rewrite_query = getBooleanParameter(req, "rewrite_query");
final boolean staleOk = Utils.getStaleOk(req);
- final IndexKey key;
- try {
- key = new IndexKey(req);
- } catch (final IllegalArgumentException e) {
- ServletUtils.sendJSONError(req, resp, 400, "Bad path");
- return;
- }
- lucene.startIndexing(key);
+ lucene.startIndexing(req.getPathInfo());
final SearcherCallback callback = new SearcherCallback() {
@@ -469,11 +462,11 @@ public void callback(final IndexSearcher searcher, final String version) throws
}
public void onMissing() throws IOException {
- ServletUtils.sendJSONError(req, resp, 404, "Index for " + key.getDatabaseName() + " is missing.");
+ ServletUtils.sendJSONError(req, resp, 404, "Index for " + req.getPathInfo() + " is missing.");
}
};
- lucene.withSearcher(key, staleOk, callback);
+ lucene.withSearcher(req.getPathInfo(), staleOk, callback);
}
}
View
91 src/main/java/com/github/rnewson/couchdb/lucene/ViewIndexer.java
@@ -14,13 +14,12 @@
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
+import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
@@ -31,7 +30,6 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.tika.io.IOUtils;
import org.mozilla.javascript.ClassShutter;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.RhinoException;
@@ -42,7 +40,7 @@
import com.github.rnewson.couchdb.lucene.couchdb.Database;
import com.github.rnewson.couchdb.lucene.util.Analyzers;
import com.github.rnewson.couchdb.lucene.util.Constants;
-import com.github.rnewson.couchdb.lucene.util.StatusCodeResponseHandler;
+import com.github.rnewson.couchdb.lucene.util.Utils;
public final class ViewIndexer implements Runnable {
@@ -51,17 +49,14 @@
private final Logger logger;
private HttpClient client;
private Context context;
- private final IndexKey key;
- private final CouchDbRegistry registry;
+ private final String path;
private Database database;
- private String url;
private final Lucene lucene;
- public ViewIndexer(final Lucene lucene, final CouchDbRegistry registry, final IndexKey key) {
+ public ViewIndexer(final Lucene lucene, final String path) {
this.lucene = lucene;
- this.logger = Logger.getLogger(ViewIndexer.class.getName() + "." + key.toString());
- this.registry = registry;
- this.key = key;
+ this.logger = Logger.getLogger(ViewIndexer.class.getName() + "." + path);
+ this.path = path;
}
public void run() {
@@ -86,9 +81,9 @@ private void setup() throws IOException {
context.setClassShutter(new RestrictiveClassShutter());
context.setOptimizationLevel(9);
client = httpClient();
- url = registry.createUrlByHostKey(key.getHostKey(), key.getDatabaseName());
- final Couch couch = new Couch(client, registry.createUrlByHostKey(key.getHostKey(), ""));
- database = couch.getDatabase(key.getDatabaseName());
+ final String url = String.format("http://%s:%d/", Utils.getHost(path), Utils.getPort(path));
+ final Couch couch = new Couch(client, url);
+ database = couch.getDatabase(Utils.getDatabase(path));
}
private void teardown() {
@@ -99,7 +94,7 @@ private void teardown() {
private void index() throws IOException {
final UUID uuid = getDatabaseUuid();
- final JSONObject ddoc = database.getDocument("_design/" + key.getDesignDocumentName());
+ final JSONObject ddoc = database.getDocument("_design/" + Utils.getDesignDocumentName(path));
new ViewChangesHandler(uuid, ddoc).start();
}
@@ -126,44 +121,21 @@ private JSONObject defaults() {
}
private UUID getDatabaseUuid() throws IOException {
- final HttpGet get = new HttpGet(url + "/_local/lucene");
- UUID result = client.execute(get, new UUIDHandler());
-
- if (result == null) {
- result = UUID.randomUUID();
- final String doc = String.format("{\"uuid\":\"%s\"}", result);
- final HttpPut put = new HttpPut(url + "/_local/lucene");
- put.setEntity(new StringEntity(doc));
- final int sc = client.execute(put, new StatusCodeResponseHandler());
- switch (sc) {
- case 201:
- break;
- case 404:
- case 409:
- result = getDatabaseUuid();
- break;
- default:
- throw new IOException("Unexpected error code: " + sc);
- }
- }
-
- logger.info("Database has uuid " + result);
- return result;
- }
-
- private class UUIDHandler implements ResponseHandler<UUID> {
-
- public UUID handleResponse(final HttpResponse response) throws ClientProtocolException, IOException {
- switch (response.getStatusLine().getStatusCode()) {
- case 200:
- final String body = IOUtils.toString(response.getEntity().getContent());
- final JSONObject json = JSONObject.fromObject(body);
- return UUID.fromString(json.getString("uuid"));
+ try {
+ final JSONObject local = database.getDocument("_local/lucene");
+ final UUID uuid = UUID.fromString(local.getString("uuid"));
+ logger.info("Database has uuid " + uuid);
+ return uuid;
+ } catch (final HttpResponseException e) {
+ switch (e.getStatusCode()) {
+ case HttpStatus.SC_NOT_FOUND:
+ final UUID uuid = UUID.randomUUID();
+ database.saveDocument("_local/lucene", String.format("{\"uuid\":\"%s\"}", uuid));
+ return getDatabaseUuid();
default:
- return null;
+ throw e;
}
}
-
}
private class ViewChangesHandler implements ResponseHandler<Void> {
@@ -183,9 +155,9 @@ public ViewChangesHandler(final UUID uuid, final JSONObject ddoc) throws IOExcep
analyzer = Analyzers.getAnalyzer(view.optString("analyzer", "standard"));
final String function = extractFunction(ddoc);
converter = new DocumentConverter(context, null, function);
- lucene.createWriter(key, uuid, function);
+ lucene.createWriter(path, uuid, function);
digest = Lucene.digest(function);
- lucene.withReader(key, false, new ReaderCallback() {
+ lucene.withReader(path, false, new ReaderCallback() {
public void callback(final IndexReader reader) throws IOException {
final Map commit = reader.getCommitUserData();
if (commit != null && commit.containsKey("last_seq")) {
@@ -201,7 +173,7 @@ public void onMissing() throws IOException {
private JSONObject extractView(final JSONObject ddoc) {
final JSONObject fulltext = ddoc.getJSONObject("fulltext");
- return fulltext.getJSONObject(key.getViewName());
+ return fulltext.getJSONObject(Utils.getViewName(path));
}
private String extractFunction(final JSONObject ddoc) {
@@ -209,8 +181,7 @@ private String extractFunction(final JSONObject ddoc) {
}
public void start() throws IOException {
- get = new HttpGet(url + "/_changes?feed=continuous&heartbeat=15000&include_docs=true&since=" + since);
- client.execute(get, this);
+ database.handleChanges(since, this);
}
public Void handleResponse(final HttpResponse response) throws IOException {
@@ -240,7 +211,7 @@ public Void handleResponse(final HttpResponse response) throws IOException {
final JSONObject doc = json.getJSONObject("doc");
final String id = doc.getString("_id");
- if (id.equals("_design/" + key.getDesignDocumentName())) {
+ if (id.equals("_design/" + Utils.getDesignDocumentName(path))) {
if (doc.optBoolean("_deleted")) {
logger.info("Design document for this view was deleted.");
break loop;
@@ -255,7 +226,7 @@ public Void handleResponse(final HttpResponse response) throws IOException {
continue loop;
} else if (doc.optBoolean("_deleted")) {
logger.trace(id + " deleted.");
- lucene.withWriter(key, new WriterCallback() {
+ lucene.withWriter(path, new WriterCallback() {
public boolean callback(final IndexWriter writer) throws IOException {
writer.deleteDocuments(new Term("_id", id));
@@ -277,7 +248,7 @@ public void onMissing() throws IOException {
continue loop;
}
- lucene.withWriter(key, new WriterCallback() {
+ lucene.withWriter(path, new WriterCallback() {
public boolean callback(final IndexWriter writer) throws IOException {
writer.deleteDocuments(new Term("_id", id));
@@ -303,7 +274,7 @@ private void commitDocuments() throws IOException {
if (!hasPendingCommit())
return;
- lucene.withWriter(key, new WriterCallback() {
+ lucene.withWriter(path, new WriterCallback() {
public boolean callback(final IndexWriter writer) throws IOException {
final Map<String, String> userData = new HashMap<String, String>();
userData.put("last_seq", Long.toString(since));
View
5 src/main/java/com/github/rnewson/couchdb/lucene/couchdb/Database.java
@@ -66,6 +66,11 @@ public final JSONObject getInfo() throws IOException {
return httpClient.execute(get, handler);
}
+ public <T> T handleChanges(final long since, final ResponseHandler<T> handler) throws IOException {
+ final HttpGet get = new HttpGet(url + "/_changes?feed=continuous&heartbeat=15000&include_docs=true&since=" + since);
+ return httpClient.execute(get, handler);
+ }
+
public final boolean saveDocument(final String id, final String body) throws IOException {
return HttpUtils.put(httpClient, url + Utils.urlEncode(id), body) == 201;
}
View
30 src/main/java/com/github/rnewson/couchdb/lucene/util/Utils.java
@@ -20,6 +20,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -63,5 +64,34 @@ public static String urlEncode(final String path) {
throw new Error("UTF-8 support missing!");
}
}
+
+ public static String getHost(final String path) {
+ return split(path)[0];
+ }
+
+ public static int getPort(final String path) {
+ return Integer.parseInt(split(path)[1]);
+ }
+
+ public static String getDatabase(final String path) {
+ return split(path)[2];
+ }
+
+ public static String getDesignDocumentName(final String path) {
+ return split(path)[3];
+ }
+
+ public static String getViewName(final String path) {
+ return split(path)[4];
+ }
+
+ private static String[] split(final String path) {
+ final String[] result = path.substring(1).split("/");
+ if (result.length != 5) {
+ throw new IllegalArgumentException("Malformed path (" + Arrays.toString(result) + ")");
+ }
+ return result;
+ }
+
}
View
4 src/test/resources/couchdb-lucene.properties
@@ -1,7 +1,3 @@
lucene.dir=target/indexes
lucene.log=target/couchdb-lucene.log
lucene.port=5985
-
-// Query format -- http://<host>:<port>/search/<key>/<db>/<ddoc>/<view>?q=<query>
-
-couchdb.url.local=http://localhost:5984
Please sign in to comment.
Something went wrong with that request. Please try again.