You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/01/04 13:30:47 UTC
svn commit: r1555341 [1/2] - in
/lucene/dev/branches/lucene5376/lucene/server/src:
java/org/apache/lucene/server/ java/org/apache/lucene/server/handlers/
test/org/apache/lucene/server/
Author: mikemccand
Date: Sat Jan 4 12:30:46 2014
New Revision: 1555341
URL: http://svn.apache.org/r1555341
Log:
LUCENE-5376: test sugar: insert the current index name to outgoing requests to make writing tests easier
Modified:
lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/GlobalState.java
lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/IndexState.java
lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/Server.java
lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/BuildSuggestHandler.java
lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/DeleteIndexHandler.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAddDocuments.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBlockJoinQuery.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBooleanFieldType.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestGrouping.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestHighlight.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestLiveValues.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestNumericFields.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestServer.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSettings.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSnapshots.java
lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSuggest.java
Modified: lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/GlobalState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/GlobalState.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/GlobalState.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/GlobalState.java Sat Jan 4 12:30:46 2014
@@ -204,11 +204,6 @@ public class GlobalState implements Clos
}
}
- /** Close all indices. */
- public void closeAll() throws IOException {
- IOUtils.close(indices.values());
- }
-
void loadIndexNames() throws IOException {
long gen = IndexState.getLastGen(stateDir, "indices");
lastIndicesGen = gen;
@@ -252,7 +247,8 @@ public class GlobalState implements Clos
@Override
public void close() throws IOException {
- // nocommit move closeAll into here?
+ //System.out.println("GlobalState.close");
+ IOUtils.close(indices.values());
indexService.shutdown();
}
Modified: lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/IndexState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/IndexState.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/IndexState.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/IndexState.java Sat Jan 4 12:30:46 2014
@@ -822,9 +822,10 @@ public class IndexState implements Close
@Override
public synchronized void close() throws IOException {
+ //System.out.println("IndexState.close name=" + name + " writer=" + writer);
+ commit();
// nocommit catch exc & rollback:
if (writer != null) {
- commit();
IOUtils.close(reopenThread,
manager,
writer.getIndexWriter(),
@@ -906,18 +907,16 @@ public class IndexState implements Close
/** Commit all state. */
public synchronized void commit() throws IOException {
- if (writer == null) {
- throw new IllegalStateException("index \"" + name + "\" isn't started: cannot commit");
+ if (writer != null) {
+ // nocommit: two phase commit?
+ taxoWriter.commit();
+ writer.getIndexWriter().commit();
}
- // nocommit: two phase commit?
- taxoWriter.commit();
- writer.getIndexWriter().commit();
-
JSONObject saveState = new JSONObject();
saveState.put("state", getSaveState());
saveLoadState.save(saveState);
- //System.out.println("DONE saveLoadState.save: " + Arrays.toString(new File(rootDir, "state").listFiles()));
+ //System.out.println("IndexState.commit name=" + name + " state=" + saveState.toJSONString(new JSONStyleIdent()));
}
/** Load all previously saved state. */
Modified: lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/Server.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/Server.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/Server.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/Server.java Sat Jan 4 12:30:46 2014
@@ -646,7 +646,6 @@ public class Server {
// Close everything:
sc.close().awaitUninterruptibly();
- globalState.closeAll();
} finally {
if (bootstrap != null) {
bootstrap.releaseExternalResources();
Modified: lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/BuildSuggestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/BuildSuggestHandler.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/BuildSuggestHandler.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/BuildSuggestHandler.java Sat Jan 4 12:30:46 2014
@@ -468,7 +468,6 @@ public class BuildSuggestHandler extends
sortFields.add(sortField);
}
}
- System.out.println("sortFields: " + sortFields);
dict = new DocumentExpressionDictionary(searcher.searcher.getIndexReader(),
suggestField,
@@ -517,6 +516,8 @@ public class BuildSuggestHandler extends
}
}
+ //System.out.println("buildSuggest: now add suggestName=" + suggestName + " to IndexState.name=" + state.name);
+
try {
state.addSuggest(suggestName, (JSONObject) JSONValue.parseStrict(jsonOrig));
} catch (ParseException pe) {
Modified: lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/DeleteIndexHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/DeleteIndexHandler.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/DeleteIndexHandler.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/java/org/apache/lucene/server/handlers/DeleteIndexHandler.java Sat Jan 4 12:30:46 2014
@@ -51,8 +51,6 @@ public class DeleteIndexHandler extends
@Override
public FinishRequest handle(final IndexState state, final Request r, Map<String,List<String>> params) throws Exception {
- state.verifyStarted(r);
-
return new FinishRequest() {
@Override
public String finish() throws IOException {
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java Sat Jan 4 12:30:46 2014
@@ -41,10 +41,10 @@ import org.codehaus.jackson.map.ObjectMa
import org.codehaus.jackson.map.ObjectWriter;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import net.minidev.json.JSONStyle;
+import net.minidev.json.JSONStyleIdent;
import net.minidev.json.JSONValue;
import net.minidev.json.parser.ParseException;
@@ -52,6 +52,8 @@ public abstract class ServerBaseTestCase
private static Thread serverThread;
static int port;
+
+ protected static String curIndexName = "index";
protected static File TEST_DIR;
protected static File STATE_DIR;
@@ -145,12 +147,12 @@ public abstract class ServerBaseTestCase
}
protected static void createAndStartIndex() throws Exception {
- send("createIndex", "{indexName: index, rootDir: " + TEST_DIR.getAbsolutePath() + "}");
+ send("createIndex", "{indexName: " + curIndexName + ", rootDir: " + TEST_DIR.getAbsolutePath() + "}");
// Wait at most 1 msec for a searcher to reopen; this
// value is too low for a production site but for
// testing we want to minimize sleep time:
- send("liveSettings", "{indexName: index, minRefreshSec: 0.001}");
- send("startIndex", "{indexName: index}");
+ send("liveSettings", "{indexName: " + curIndexName + ", minRefreshSec: 0.001}");
+ send("startIndex", "{indexName: " + curIndexName + "}");
}
protected static void shutdownServer() throws Exception {
@@ -172,11 +174,11 @@ public abstract class ServerBaseTestCase
if (VERBOSE) {
System.out.println("TEST: deleteAllDocs");
}
- send("deleteAllDocuments", "{indexName: index}");
+ send("deleteAllDocuments", "{indexName: " + curIndexName + "}");
}
protected static void commit() throws Exception {
- send("commit", "{indexName: index}");
+ send("commit", "{indexName: " + curIndexName + "}");
}
protected static JSONObject send(String command, String args) throws Exception {
@@ -185,11 +187,35 @@ public abstract class ServerBaseTestCase
if (o == null) {
throw new IllegalArgumentException("invalid JSON: " + args);
}
+
return send(command, o);
}
+ private static boolean requiresIndexName(String command) {
+ // nocommit which commands don't?
+ return true;
+ }
+
protected static JSONObject send(String command, JSONObject args) throws Exception {
- return sendRaw(command, args.toJSONString(JSONStyle.NO_COMPRESS));
+ // Auto-insert indexName:
+ if (curIndexName != null && requiresIndexName(command) && args.get("indexName") == null) {
+ if (VERBOSE) {
+ System.out.println("NOTE: ServerBaseTestCase: now add current indexName: " + curIndexName);
+ }
+ args.put("indexName", curIndexName);
+ }
+
+ if (VERBOSE) {
+ System.out.println("\nNOTE: ServerBaseTestCase: sendRaw command=" + command + " args:\n" + args.toJSONString(new JSONStyleIdent()));
+ }
+
+ JSONObject result = sendRaw(command, args.toJSONString(JSONStyle.NO_COMPRESS));
+
+ if (VERBOSE) {
+ System.out.println("NOTE: ServerBaseTestCase: server response:\n" + result.toJSONString(new JSONStyleIdent()));
+ }
+
+ return result;
}
protected static JSONObject sendRaw(String command, String body) throws Exception {
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAddDocuments.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAddDocuments.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAddDocuments.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAddDocuments.java Sat Jan 4 12:30:46 2014
@@ -32,7 +32,7 @@ public class TestAddDocuments extends Se
startServer();
createAndStartIndex();
registerFields();
- commit();
+ //commit();
}
@AfterClass
@@ -41,7 +41,7 @@ public class TestAddDocuments extends Se
}
private static void registerFields() throws Exception {
- send("registerFields", "{indexName: index, fields: {docType: {type: atom}, name: {type: atom}, country: {type: atom}, skill: {type: atom}, year: {type: int}}}");
+ send("registerFields", "{fields: {docType: {type: atom}, name: {type: atom}, country: {type: atom}, skill: {type: atom}, year: {type: int}}}");
}
private JSONObject getResume(String name, String country) {
@@ -77,11 +77,11 @@ public class TestAddDocuments extends Se
long indexGen = ((Number) result.get("indexGen")).longValue();
// search on parent:
- result = send("search", String.format(Locale.ROOT, "{indexName: index, queryText: 'name:Lisa', searcher: {indexGen: %d}}", indexGen));
+ result = send("search", String.format(Locale.ROOT, "{queryText: 'name:Lisa', searcher: {indexGen: %d}}", indexGen));
assertEquals(1, result.get("totalHits"));
// search on child:
- result = send("search", String.format(Locale.ROOT, "{indexName: index, queryText: 'skill:python', searcher: {indexGen: %d}}", indexGen));
+ result = send("search", String.format(Locale.ROOT, "{queryText: 'skill:python', searcher: {indexGen: %d}}", indexGen));
assertEquals(1, result.get("totalHits"));
}
@@ -110,11 +110,11 @@ public class TestAddDocuments extends Se
long indexGen = ((Number) result.get("indexGen")).longValue();
// search on parent:
- result = send("search", String.format(Locale.ROOT, "{indexName: index, queryText: 'name:Lisa', searcher: {indexGen: %d}}", indexGen));
+ result = send("search", String.format(Locale.ROOT, "{queryText: 'name:Lisa', searcher: {indexGen: %d}}", indexGen));
assertEquals(100, result.get("totalHits"));
// search on child:
- result = send("search", String.format(Locale.ROOT, "{indexName: index, queryText: 'skill:python', searcher: {indexGen: %d}}", indexGen));
+ result = send("search", String.format(Locale.ROOT, "{queryText: 'skill:python', searcher: {indexGen: %d}}", indexGen));
assertEquals(100, result.get("totalHits"));
}
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java Sat Jan 4 12:30:46 2014
@@ -30,6 +30,7 @@ public class TestAnalysis extends Server
@BeforeClass
public static void initClass() throws Exception {
+ curIndexName = "index";
startServer();
createAndStartIndex();
}
@@ -39,74 +40,81 @@ public class TestAnalysis extends Server
shutdownServer();
}
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ curIndexName = "index";
+ }
+
public void testCustomAnalysisChain() throws Exception {
//send("{body: {type: text, analyzer: {tokenizer: StandardTokenizer, tokenFilters: [LowerCaseFilter]}}}", "registerFields");
//send("{queryParser: {class: classic, defaultField: body}}", "settings");
- JSONObject o = send("analyze", "{indexName: index, text: 'Here is some text', analyzer: {tokenizer: StandardTokenizer, tokenFilters: [LowerCaseFilter]}}");
+ JSONObject o = send("analyze", "{text: 'Here is some text', analyzer: {tokenizer: StandardTokenizer, tokenFilters: [LowerCaseFilter]}}");
assertEquals("here is some text", justTokens(o));
- o = send("analyze", "{indexName: index, text: 'Here is some text', analyzer: {tokenizer: StandardTokenizer}}");
+ o = send("analyze", "{text: 'Here is some text', analyzer: {tokenizer: StandardTokenizer}}");
assertEquals("Here is some text", justTokens(o));
- o = send("analyze", "{indexName: index, text: 'Here is some text', analyzer: {tokenizer: {class: StandardTokenizer, maxTokenLength: 2}, tokenFilters: [LowerCaseFilter]}}");
+ o = send("analyze", "{text: 'Here is some text', analyzer: {tokenizer: {class: StandardTokenizer, maxTokenLength: 2}, tokenFilters: [LowerCaseFilter]}}");
assertEquals("is", justTokens(o));
// test maxTokenLength
}
public void testPatternTokenizer() throws Exception {
- JSONObject o = send("analyze", "{indexName: index, text: 'Here is \\'some\\' text', analyzer: {tokenizer: {class: PatternTokenizer, pattern: \"\\'([^\\']+)\\'\", group: 1}}}");
+ JSONObject o = send("analyze", "{text: 'Here is \\'some\\' text', analyzer: {tokenizer: {class: PatternTokenizer, pattern: \"\\'([^\\']+)\\'\", group: 1}}}");
assertEquals("some", justTokens(o));
}
public void testSetKeywordMarkerFilter() throws Exception {
// No KWMarkerFilter, dogs is stemmed:
- JSONObject o = send("analyze", "{indexName: index, text: 'Here is some dogs', analyzer: {tokenizer: StandardTokenizer, tokenFilters: [EnglishPossessiveFilter, LowerCaseFilter, StopFilter, EnglishMinimalStemFilter]}}}");
+ JSONObject o = send("analyze", "{text: 'Here is some dogs', analyzer: {tokenizer: StandardTokenizer, tokenFilters: [EnglishPossessiveFilter, LowerCaseFilter, StopFilter, EnglishMinimalStemFilter]}}}");
assertEquals("here some dog", justTokens(o));
// KWMarkerFilter protects dogs:
- o = send("analyze", "{indexName: index, text: 'Here is some dogs', analyzer: {tokenizer: StandardTokenizer, tokenFilters: [EnglishPossessiveFilter, LowerCaseFilter, StopFilter, {class: SetKeywordMarkerFilter, keyWords:[dogs]}, EnglishMinimalStemFilter]}}}");
+ o = send("analyze", "{text: 'Here is some dogs', analyzer: {tokenizer: StandardTokenizer, tokenFilters: [EnglishPossessiveFilter, LowerCaseFilter, StopFilter, {class: SetKeywordMarkerFilter, keyWords:[dogs]}, EnglishMinimalStemFilter]}}}");
assertEquals("here some dogs", justTokens(o));
}
public void testEnglishAnalyzer() throws Exception {
- JSONObject o = send("analyze", "{indexName: index, text: 'dogs go running', analyzer: {class: EnglishAnalyzer}}");
+ JSONObject o = send("analyze", "{text: 'dogs go running', analyzer: {class: EnglishAnalyzer}}");
assertEquals("dog go run", justTokens(o));
// This time protecting dogs from stemming:
- o = send("analyze", "{indexName: index, text: 'dogs go running', analyzer: {class: EnglishAnalyzer, stemExclusionSet: [dogs]}}");
+ o = send("analyze", "{text: 'dogs go running', analyzer: {class: EnglishAnalyzer, stemExclusionSet: [dogs]}}");
assertEquals("dogs go run", justTokens(o));
}
public void testPositionIncrementGap() throws Exception {
+ curIndexName = "posinc";
_TestUtil.rmDir(new File("posinc"));
- send("createIndex", "{indexName: posinc, rootDir: posinc}");
- send("settings", "{indexName: posinc, directory: RAMDirectory}");
- send("registerFields", "{indexName: posinc, fields: {author1: {type: text, analyzer: {tokenizer: WhitespaceTokenizer}, multiValued: true}, author2: {type: text, analyzer: {tokenizer: WhitespaceTokenizer, positionIncrementGap: 1}, multiValued: true}}}");
- send("startIndex", "{indexName: posinc}");
- long gen = getLong(send("addDocument", "{indexName: posinc, fields: {author1: [bob, smith], author2: [bob, smith]}}"), "indexGen");
+ send("createIndex", "{rootDir: posinc}");
+ send("settings", "{directory: RAMDirectory}");
+ send("registerFields", "{fields: {author1: {type: text, analyzer: {tokenizer: WhitespaceTokenizer}, multiValued: true}, author2: {type: text, analyzer: {tokenizer: WhitespaceTokenizer, positionIncrementGap: 1}, multiValued: true}}}");
+ send("startIndex", "{}");
+ long gen = getLong(send("addDocument", "{fields: {author1: [bob, smith], author2: [bob, smith]}}"), "indexGen");
// This one matches because the two values act like they
// were just concatenated:
- JSONObject result = send("search", String.format(Locale.ROOT, "{indexName: posinc, queryText: 'author1: \"bob smith\"', searcher: {indexGen: %d}}", gen));
+ JSONObject result = send("search", String.format(Locale.ROOT, "{queryText: 'author1: \"bob smith\"', searcher: {indexGen: %d}}", gen));
assertEquals(1, getInt(result, "hits.length"));
// This one doesn't match because a hole is inserted
// between the two values:
- result = send("search", String.format(Locale.ROOT, "{indexName: posinc, queryText: 'author2: \"bob smith\"', searcher: {indexGen: %d}}", gen));
+ result = send("search", String.format(Locale.ROOT, "{queryText: 'author2: \"bob smith\"', searcher: {indexGen: %d}}", gen));
assertEquals(0, getInt(result, "hits.length"));
- send("stopIndex", "{indexName: posinc}");
- send("deleteIndex", "{indexName: posinc}");
+ send("stopIndex", "{}");
+ send("deleteIndex", "{}");
}
public void testSynonymFilter() throws Exception {
- JSONObject o = send("analyze", "{indexName: index, text: 'domain name service is complex', analyzer: {tokenizer: WhitespaceTokenizer, tokenFilters: [LowerCaseFilter, {class: SynonymFilter, ignoreCase: true, analyzer: WhitespaceAnalyzer, synonyms: [{input: 'domain name service', output: 'dns'}]}]}}");
+ JSONObject o = send("analyze", "{text: 'domain name service is complex', analyzer: {tokenizer: WhitespaceTokenizer, tokenFilters: [LowerCaseFilter, {class: SynonymFilter, ignoreCase: true, analyzer: WhitespaceAnalyzer, synonyms: [{input: 'domain name service', output: 'dns'}]}]}}");
assertEquals("dns/0 is/1 complex/2", tokensAndPositions(o));
- o = send("analyze", "{indexName: index, text: 'domain name service is complex', analyzer: {tokenizer: WhitespaceTokenizer, tokenFilters: [LowerCaseFilter, {class: SynonymFilter, ignoreCase: true, analyzer: WhitespaceAnalyzer, synonyms: [{input: 'domain name service', output: 'dns', replace: false}]}]}}");
+ o = send("analyze", "{text: 'domain name service is complex', analyzer: {tokenizer: WhitespaceTokenizer, tokenFilters: [LowerCaseFilter, {class: SynonymFilter, ignoreCase: true, analyzer: WhitespaceAnalyzer, synonyms: [{input: 'domain name service', output: 'dns', replace: false}]}]}}");
assertEquals("domain/0 dns/0:3 name/1 service/2 is/3 complex/4", tokensAndPositions(o));
- o = send("analyze", "{indexName: index, text: 'mother knows best', analyzer: {tokenizer: WhitespaceTokenizer, tokenFilters: [LowerCaseFilter, {class: SynonymFilter, ignoreCase: true, analyzer: WhitespaceAnalyzer, synonyms: [{input: ['mother', 'mommy'], output: 'mom'}]}]}}");
+ o = send("analyze", "{text: 'mother knows best', analyzer: {tokenizer: WhitespaceTokenizer, tokenFilters: [LowerCaseFilter, {class: SynonymFilter, ignoreCase: true, analyzer: WhitespaceAnalyzer, synonyms: [{input: ['mother', 'mommy'], output: 'mom'}]}]}}");
assertEquals("mom/0 knows/1 best/2", tokensAndPositions(o));
}
@@ -129,7 +137,7 @@ public class TestAnalysis extends Server
"$NonWhitespace+ {1};";
public void testICUTokenizer() throws Exception {
- JSONObject o = send("analyze", "{indexName: index, text: 'domain-name service is complex', analyzer: {tokenizer: {class: ICUTokenizer, rules: [{script: Latn, rules: \"" + ONLY_WHITESPACE_RULES + "\"}]}}}");
+ JSONObject o = send("analyze", "{text: 'domain-name service is complex', analyzer: {tokenizer: {class: ICUTokenizer, rules: [{script: Latn, rules: \"" + ONLY_WHITESPACE_RULES + "\"}]}}}");
assertEquals("domain-name/0 service/1 is/2 complex/3", tokensAndPositions(o));
}
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBlockJoinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBlockJoinQuery.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBlockJoinQuery.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBlockJoinQuery.java Sat Jan 4 12:30:46 2014
@@ -26,6 +26,7 @@ public class TestBlockJoinQuery extends
@BeforeClass
public static void initClass() throws Exception {
+ curIndexName = "index";
startServer();
createAndStartIndex();
registerFields();
@@ -38,7 +39,7 @@ public class TestBlockJoinQuery extends
}
private static void registerFields() throws Exception {
- send("registerFields", "{indexName: index, fields: {docType: {type: atom}, name: {type: atom, store: true}, country: {type: atom, store: true}, skill: {type: atom, store: true}, year: {type: int, store: true}}}");
+ send("registerFields", "{fields: {docType: {type: atom}, name: {type: atom, store: true}, country: {type: atom, store: true}, skill: {type: atom, store: true}, year: {type: int, store: true}}}");
}
private JSONObject getResume(String name, String country) {
@@ -74,11 +75,11 @@ public class TestBlockJoinQuery extends
long indexGen = ((Number) result.get("indexGen")).longValue();
// search on parent:
- result = send("search", "{indexName: index, query: {class: ToParentBlockJoinQuery, childQuery: {class: text, field: skill, text: python}, parentsFilter: {class: CachingWrapperFilter, filter: {class: QueryWrapperFilter, query: {class: TermQuery, field: docType, term: resume}}}}, searcher: {indexGen: " + indexGen + "}}");
+ result = send("search", "{query: {class: ToParentBlockJoinQuery, childQuery: {class: text, field: skill, text: python}, parentsFilter: {class: CachingWrapperFilter, filter: {class: QueryWrapperFilter, query: {class: TermQuery, field: docType, term: resume}}}}, searcher: {indexGen: " + indexGen + "}}");
//System.out.println("GOT: " + result);
assertEquals(1, getInt(result, "totalHits"));
- result = send("search", "{indexName: index, retrieveFields: [skill, year, name, country], query: {class: ToParentBlockJoinQuery, childHits: {}, childQuery: {class: text, field: skill, text: python}, parentsFilter: {class: CachingWrapperFilter, filter: {class: QueryWrapperFilter, query: {class: TermQuery, field: docType, term: resume}}}}, searcher: {indexGen: " + indexGen + "}}");
+ result = send("search", "{retrieveFields: [skill, year, name, country], query: {class: ToParentBlockJoinQuery, childHits: {}, childQuery: {class: text, field: skill, text: python}, parentsFilter: {class: CachingWrapperFilter, filter: {class: QueryWrapperFilter, query: {class: TermQuery, field: docType, term: resume}}}}, searcher: {indexGen: " + indexGen + "}}");
//System.out.println("GOT: " + prettyPrint(result));
// nocommit why is this 0?
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBooleanFieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBooleanFieldType.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBooleanFieldType.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestBooleanFieldType.java Sat Jan 4 12:30:46 2014
@@ -25,6 +25,7 @@ public class TestBooleanFieldType extend
@BeforeClass
public static void initClass() throws Exception {
+ curIndexName = "index";
startServer();
createAndStartIndex();
registerFields();
@@ -49,9 +50,9 @@ public class TestBooleanFieldType extend
public void testStored() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {id: 0, flagStored: false}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {id: 1, flagStored: true}}"), "indexGen");
- JSONObject o = send("search", "{indexName: index, searcher: {indexGen: " + gen + "}, query: MatchAllDocsQuery, retrieveFields: [id, flagStored]}");
+ send("addDocument", "{fields: {id: 0, flagStored: false}}");
+ long gen = getLong(send("addDocument", "{fields: {id: 1, flagStored: true}}"), "indexGen");
+ JSONObject o = send("search", "{searcher: {indexGen: " + gen + "}, query: MatchAllDocsQuery, retrieveFields: [id, flagStored]}");
assertEquals(2, getInt(o, "totalHits"));
assertFalse(getBoolean(o, "hits[0].fields.flagStored"));
assertTrue(getBoolean(o, "hits[1].fields.flagStored"));
@@ -59,9 +60,9 @@ public class TestBooleanFieldType extend
public void testIndexed() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {id: 0, flagIndexed: false, flagStored: false}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {id: 1, flagIndexed: true, flagStored: true}}"), "indexGen");
- JSONObject o = send("search", "{indexName: index, searcher: {indexGen: " + gen + "}, query: MatchAllDocsQuery, filter: {class: BooleanFieldFilter, field: flagIndexed}, retrieveFields: [id, flagStored]}");
+ send("addDocument", "{fields: {id: 0, flagIndexed: false, flagStored: false}}");
+ long gen = getLong(send("addDocument", "{fields: {id: 1, flagIndexed: true, flagStored: true}}"), "indexGen");
+ JSONObject o = send("search", "{searcher: {indexGen: " + gen + "}, query: MatchAllDocsQuery, filter: {class: BooleanFieldFilter, field: flagIndexed}, retrieveFields: [id, flagStored]}");
assertEquals(1, getInt(o, "totalHits"));
assertTrue(getBoolean(o, "hits[0].fields.flagStored"));
}
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java Sat Jan 4 12:30:46 2014
@@ -28,6 +28,7 @@ public class TestFacets extends ServerBa
@BeforeClass
public static void initClass() throws Exception {
+ curIndexName = "index";
startServer();
createAndStartIndex();
registerFields();
@@ -179,25 +180,25 @@ public class TestFacets extends ServerBa
public void testDrillSideways() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {author: Bob}}");
- send("addDocument", "{indexName: index, fields: {author: Lisa}}");
- send("addDocument", "{indexName: index, fields: {author: Lisa}}");
- send("addDocument", "{indexName: index, fields: {author: Tom}}");
- send("addDocument", "{indexName: index, fields: {author: Tom}}");
- long indexGen = getLong(send("addDocument", "{indexName: index, fields: {author: Tom}}"), "indexGen");
+ send("addDocument", "{fields: {author: Bob}}");
+ send("addDocument", "{fields: {author: Lisa}}");
+ send("addDocument", "{fields: {author: Lisa}}");
+ send("addDocument", "{fields: {author: Tom}}");
+ send("addDocument", "{fields: {author: Tom}}");
+ long indexGen = getLong(send("addDocument", "{fields: {author: Tom}}"), "indexGen");
// Initial query:
- JSONObject o = send("search", String.format(Locale.ROOT, "{indexName: index, query: MatchAllDocsQuery, facets: [{path: [author], topN: 10}], searcher: {indexGen: %d}}", indexGen));
+ JSONObject o = send("search", String.format(Locale.ROOT, "{query: MatchAllDocsQuery, facets: [{path: [author], topN: 10}], searcher: {indexGen: %d}}", indexGen));
assertEquals(6, o.get("totalHits"));
assertEquals("[[\"top\",0],[\"Tom\",3],[\"Lisa\",2],[\"Bob\",1]]", getArray(o, "facets[0].counts").toString());
// Now, single drill down:
- o = send("search", String.format(Locale.ROOT, "{indexName: index, drillDowns: [{field: author, values: [Bob]}], query: MatchAllDocsQuery, facets: [{path: [author], topN: 10}], searcher: {indexGen: %d}}", indexGen));
+ o = send("search", String.format(Locale.ROOT, "{drillDowns: [{field: author, values: [Bob]}], query: MatchAllDocsQuery, facets: [{path: [author], topN: 10}], searcher: {indexGen: %d}}", indexGen));
assertEquals(1, o.get("totalHits"));
assertEquals("[[\"top\",0],[\"Tom\",3],[\"Lisa\",2],[\"Bob\",1]]", getArray(o, "facets[0].counts").toString());
// Multi drill down:
- o = send("search", String.format(Locale.ROOT, "{indexName: index, drillDowns: [{field: author, values: [Bob, Lisa]}], query: MatchAllDocsQuery, facets: [{path: [author], topN: 10}], searcher: {indexGen: %d}}", indexGen));
+ o = send("search", String.format(Locale.ROOT, "{drillDowns: [{field: author, values: [Bob, Lisa]}], query: MatchAllDocsQuery, facets: [{path: [author], topN: 10}], searcher: {indexGen: %d}}", indexGen));
assertEquals(3, o.get("totalHits"));
assertEquals("[[\"top\",0],[\"Tom\",3],[\"Lisa\",2],[\"Bob\",1]]", getArray(o, "facets[0].counts").toString());
}
@@ -206,9 +207,9 @@ public class TestFacets extends ServerBa
deleteAllDocs();
long gen = -1;
for(int i=0;i<100;i++) {
- gen = getLong(send("addDocument", "{indexName: index, fields: {longField: " + i + "}}"), "indexGen");
+ gen = getLong(send("addDocument", "{fields: {longField: " + i + "}}"), "indexGen");
}
- JSONObject o = send("search", "{indexName: index, facets: [{path: longField, numericRanges: [{label: All, min: 0, max: 99, minInclusive: true, maxInclusive: true}, {label: Half, min: 0, max: 49, minInclusive: true, maxInclusive: true}]}], searcher: {indexGen: " + gen + "}}");
+ JSONObject o = send("search", "{facets: [{path: longField, numericRanges: [{label: All, min: 0, max: 99, minInclusive: true, maxInclusive: true}, {label: Half, min: 0, max: 49, minInclusive: true, maxInclusive: true}]}], searcher: {indexGen: " + gen + "}}");
assertEquals("All", getString(o, "facets[0].counts[1][0]"));
assertEquals(100, getInt(o, "facets[0].counts[1][1]"));
assertEquals("Half", getString(o, "facets[0].counts[2][0]"));
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestGrouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestGrouping.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestGrouping.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestGrouping.java Sat Jan 4 12:30:46 2014
@@ -26,6 +26,7 @@ public class TestGrouping extends Server
@BeforeClass
public static void initClass() throws Exception {
+ curIndexName = "index";
startServer();
createAndStartIndex();
registerFields();
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestHighlight.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestHighlight.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestHighlight.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestHighlight.java Sat Jan 4 12:30:46 2014
@@ -38,6 +38,12 @@ public class TestHighlight extends Serve
shutdownServer();
}
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ curIndexName = "index";
+ }
+
private static void registerFields() throws Exception {
JSONObject o = new JSONObject();
put(o, "body", "{type: text, highlight: true, store: true, analyzer: {class: StandardAnalyzer, matchVersion: LUCENE_43}, similarity: {class: BM25Similarity, b: 0.15}}");
@@ -142,8 +148,8 @@ public class TestHighlight extends Serve
public void testMultiValuedWholeHighlight() throws Exception {
deleteAllDocs();
- long gen = addDocument("{indexName: index, fields: {authors: ['Dr. Seuss', 'Bob Smith', 'Seuss is Fun. Some extra content.']}}");
- JSONObject result = send("search", "{indexName: index, queryText: 'authors:seuss', retrieveFields: [{field: authors, highlight: whole}], searcher: {indexGen: " + gen + "}}");
+ long gen = addDocument("{fields: {authors: ['Dr. Seuss', 'Bob Smith', 'Seuss is Fun. Some extra content.']}}");
+ JSONObject result = send("search", "{queryText: 'authors:seuss', retrieveFields: [{field: authors, highlight: whole}], searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
JSONArray fields = getArray(result, "hits[0].fields.authors");
assertEquals(3, fields.size());
@@ -155,8 +161,8 @@ public class TestHighlight extends Serve
public void testMultiValuedSnippetHighlight() throws Exception {
deleteAllDocs();
- long gen = addDocument("{indexName: index, fields: {authors: ['Dr. Seuss', 'Bob Smith', 'Seuss is Fun. Some extra content.']}}");
- JSONObject result = send("search", "{indexName: index, queryText: 'authors:seuss', retrieveFields: [{field: authors, highlight: snippets, maxPassages: 1}], searcher: {indexGen: " + gen + "}}");
+ long gen = addDocument("{fields: {authors: ['Dr. Seuss', 'Bob Smith', 'Seuss is Fun. Some extra content.']}}");
+ JSONObject result = send("search", "{queryText: 'authors:seuss', retrieveFields: [{field: authors, highlight: snippets, maxPassages: 1}], searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
assertEquals(1, getInt(result, "hits[0].fields.authors.length"));
assertEquals("<b>Seuss</b> Bob Smith <b>Seuss</b> is Fun. ", renderSingleHighlight(getArray(result, "hits[0].fields.authors[0].parts")));
@@ -165,8 +171,8 @@ public class TestHighlight extends Serve
/** Make sure we can use a different maxPassages per field */
public void testPerFieldMaxPassages() throws Exception {
deleteAllDocs();
- long gen = addDocument("{indexName: index, fields: {body: 'This sentence has test. This one does not. Here is test again.', authors: ['This sentence has test. This one does not. Here is test again.']}}");
- JSONObject result = send("search", "{indexName: index, queryText: 'test', retrieveFields: [{field: authors, highlight: snippets, maxPassages: 1}, {field: body, highlight: snippets, maxPassages: 2}], searcher: {indexGen: " + gen + "}}");
+ long gen = addDocument("{fields: {body: 'This sentence has test. This one does not. Here is test again.', authors: ['This sentence has test. This one does not. Here is test again.']}}");
+ JSONObject result = send("search", "{queryText: 'test', retrieveFields: [{field: authors, highlight: snippets, maxPassages: 1}, {field: body, highlight: snippets, maxPassages: 2}], searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
// Author has just 1 passage:
@@ -183,7 +189,7 @@ public class TestHighlight extends Serve
public void testContentWithSep() throws Exception {
deleteAllDocs();
try {
- addDocument("{indexName: index, fields: {authors: ['Dr. Seuss', 'Bob \u001F Smith', 'Seuss is Fun']}}");
+ addDocument("{fields: {authors: ['Dr. Seuss', 'Bob \u001F Smith', 'Seuss is Fun']}}");
fail("didn't hit exception");
} catch (IOException ioe) {
// expected
@@ -195,26 +201,26 @@ public class TestHighlight extends Serve
public void testNonDefaultOffsetGap() throws Exception {
// nocommit add test infra to create a randomly named new index?
_TestUtil.rmDir(new File("offsetgap"));
- send("createIndex", "{indexName: offsetgap, rootDir: offsetgap}");
+ curIndexName = "offsetgap";
+ send("createIndex", "{rootDir: offsetgap}");
// Wait at most 1 msec for a searcher to reopen; this
// value is too low for a production site but for
// testing we want to minimize sleep time:
- send("liveSettings", "{indexName: offsetgap, minRefreshSec: 0.001}");
- send("startIndex", "{indexName: offsetgap}");
+ send("liveSettings", "{minRefreshSec: 0.001}");
+ send("startIndex", "{}");
JSONObject o = new JSONObject();
put(o, "body", "{type: text, multiValued: true, highlight: true, store: true, analyzer: {tokenizer: StandardTokenizer, offsetGap: 100}}");
JSONObject o2 = new JSONObject();
o2.put("fields", o);
- o2.put("indexName", "offsetgap");
send("registerFields", o2);
// Index one document:
- long indexGen = getLong(send("addDocument", "{indexName: offsetgap, fields: {body: ['highlight me', 'highlight me too']}}"), "indexGen");
+ long indexGen = getLong(send("addDocument", "{fields: {body: ['highlight me', 'highlight me too']}}"), "indexGen");
// Search w/ highlight:
- JSONObject result = send("search", "{indexName: offsetgap, queryText: highlight, retrieveFields: [{field: 'body', highlight: 'whole'}]}");
+ JSONObject result = send("search", "{queryText: highlight, retrieveFields: [{field: 'body', highlight: 'whole'}]}");
JSONArray parts = getArray(result, "hits[0].fields.body");
assertEquals(2, parts.size());
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java Sat Jan 4 12:30:46 2014
@@ -41,6 +41,12 @@ public class TestIndexing extends Server
shutdownServer();
}
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ curIndexName = "index";
+ }
+
private static void registerFields() throws Exception {
JSONObject o = new JSONObject();
put(o, "body", "{type: text, highlight: true, store: true, analyzer: {class: StandardAnalyzer, matchVersion: LUCENE_43}, similarity: {class: BM25Similarity, b: 0.15}}");
@@ -51,15 +57,14 @@ public class TestIndexing extends Server
put(o, "author", "{type: text, index: false, facet: flat, store: true, group: true}");
put(o, "charCount", "{type: int, store: true}");
JSONObject o2 = new JSONObject();
- o2.put("indexName", "index");
o2.put("fields", o);
send("registerFields", o2);
}
public void testUpdateDocument() throws Exception {
- send("addDocument", "{indexName: index, fields: {body: 'here is a test', id: '0'}}");
- long gen = getLong(send("updateDocument", "{indexName: index, term: {field: id, term: '0'}, fields: {body: 'here is another test', id: '0'}}"), "indexGen");
- JSONObject o = send("search", "{indexName: index, queryText: 'body:test', searcher: {indexGen: " + gen + "}, retrieveFields: [body]}");
+ send("addDocument", "{fields: {body: 'here is a test', id: '0'}}");
+ long gen = getLong(send("updateDocument", "{term: {field: id, term: '0'}, fields: {body: 'here is another test', id: '0'}}"), "indexGen");
+ JSONObject o = send("search", "{queryText: 'body:test', searcher: {indexGen: " + gen + "}, retrieveFields: [body]}");
assertEquals(1, getInt(o, "totalHits"));
assertEquals("here is another test", getString(o, "hits[0].fields.body"));
}
@@ -86,7 +91,7 @@ public class TestIndexing extends Server
JSONObject result = sendChunked(s, "bulkAddDocument");
assertEquals(100, result.get("indexedDocumentCount"));
long indexGen = ((Number) result.get("indexGen")).longValue();
- assertEquals(1, getInt(send("search", "{indexName: index, queryText: 'body:99', searcher: {indexGen: " + indexGen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{queryText: 'body:99', searcher: {indexGen: " + indexGen + "}}"), "totalHits"));
// Now, update:
sb = new StringBuilder();
@@ -110,9 +115,9 @@ public class TestIndexing extends Server
result = sendChunked(s, "bulkUpdateDocument");
assertEquals(100, result.get("indexedDocumentCount"));
indexGen = ((Number) result.get("indexGen")).longValue();
- assertEquals(1, getInt(send("search", "{indexName: index, queryText: 'body:99', searcher: {indexGen: " + indexGen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{queryText: 'body:99', searcher: {indexGen: " + indexGen + "}}"), "totalHits"));
- assertEquals(100, getInt(send("search", "{indexName: index, query: MatchAllDocsQuery, searcher: {indexGen: " + indexGen + "}}"), "totalHits"));
+ assertEquals(100, getInt(send("search", "{query: MatchAllDocsQuery, searcher: {indexGen: " + indexGen + "}}"), "totalHits"));
}
public void testBulkAddException() throws Exception {
@@ -221,45 +226,44 @@ public class TestIndexing extends Server
* after index is stopped */
public void testAddAfterStop() throws Exception {
deleteAllDocs();
- send("stopIndex", "{indexName: index}");
+ send("stopIndex", "{}");
try {
- send("addDocument", "{indexName: index, fields: {}}");
+ send("addDocument", "{fields: {}}");
fail();
} catch (IOException ioe) {
// expected
}
- send("startIndex", "{indexName: index}");
+ send("startIndex", "{}");
}
public void testBoost() throws Exception {
- // nocommit make test infra class that is for one index
- // and auto-inserts indexName: xxx into each request
_TestUtil.rmDir(new File("boost"));
- send("createIndex", "{indexName: boost, rootDir: boost}");
- send("settings", "{indexName: boost, directory: RAMDirectory, matchVersion: LUCENE_40}");
+ curIndexName = "boost";
+ send("createIndex", "{rootDir: boost}");
+ send("settings", "{directory: RAMDirectory, matchVersion: LUCENE_40}");
// Just to test index.ramBufferSizeMB:
- send("liveSettings", "{indexName: boost, index.ramBufferSizeMB: 20.0}");
- send("registerFields", "{indexName: boost, fields: {id: {type: atom, store: true}, body: {type: text, analyzer: StandardAnalyzer}}}");
- send("startIndex", "{indexName: boost}");
- send("addDocument", "{indexName: boost, fields: {id: '0', body: 'here is a test'}}");
- long gen = getLong(send("addDocument", "{indexName: boost, fields: {id: '1', body: 'here is a test'}}"), "indexGen");
- JSONObject result = send("search", String.format(Locale.ROOT, "{indexName: boost, retrieveFields: [id], queryText: test, searcher: {indexGen: %d}}", gen));
+ send("liveSettings", "{index.ramBufferSizeMB: 20.0}");
+ send("registerFields", "{fields: {id: {type: atom, store: true}, body: {type: text, analyzer: StandardAnalyzer}}}");
+ send("startIndex", "{}");
+ send("addDocument", "{fields: {id: '0', body: 'here is a test'}}");
+ long gen = getLong(send("addDocument", "{fields: {id: '1', body: 'here is a test'}}"), "indexGen");
+ JSONObject result = send("search", String.format(Locale.ROOT, "{retrieveFields: [id], queryText: test, searcher: {indexGen: %d}}", gen));
assertEquals(2, getInt(result, "hits.length"));
// Unboosted, the hits come back in order they were added:
assertEquals("0", getString(result, "hits[0].fields.id"));
assertEquals("1", getString(result, "hits[1].fields.id"));
// Do it again, this time setting higher boost for 2nd doc:
- send("deleteAllDocuments", "{indexName: boost}");
- send("addDocument", "{indexName: boost, fields: {id: '0', body: 'here is a test'}}");
- gen = getLong(send("addDocument", "{indexName: boost, fields: {id: '1', body: {boost: 2.0, value: 'here is a test'}}}"), "indexGen");
- result = send("search", String.format(Locale.ROOT, "{indexName: boost, retrieveFields: [id], queryText: test, searcher: {indexGen: %d}}", gen));
+ send("deleteAllDocuments", "{}");
+ send("addDocument", "{fields: {id: '0', body: 'here is a test'}}");
+ gen = getLong(send("addDocument", "{fields: {id: '1', body: {boost: 2.0, value: 'here is a test'}}}"), "indexGen");
+ result = send("search", String.format(Locale.ROOT, "{retrieveFields: [id], queryText: test, searcher: {indexGen: %d}}", gen));
assertEquals(2, getInt(result, "hits.length"));
// Unboosted, the hits come back in order they were added:
assertEquals("1", getString(result, "hits[0].fields.id"));
assertEquals("0", getString(result, "hits[1].fields.id"));
- send("stopIndex", "{indexName: boost}");
- send("deleteIndex", "{indexName: boost}");
+ send("stopIndex", "{}");
+ send("deleteIndex", "{}");
}
}
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestLiveValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestLiveValues.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestLiveValues.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestLiveValues.java Sat Jan 4 12:30:46 2014
@@ -38,8 +38,8 @@ public class TestLiveValues extends Serv
}
private static void registerFields() throws Exception {
- send("registerFields", "{indexName: index, fields: {id: {type: atom, store: true, postingsFormat: Memory}}}");
- send("registerFields", "{indexName: index, fields: {value: {type: atom, index: false, store: true, liveValues: id}}}");
+ send("registerFields", "{fields: {id: {type: atom, store: true, postingsFormat: Memory}}}");
+ send("registerFields", "{fields: {value: {type: atom, index: false, store: true, liveValues: id}}}");
}
// nocommit testDeletions
@@ -47,7 +47,7 @@ public class TestLiveValues extends Serv
public void testLiveFields() throws Exception {
JSONArray arr = new JSONArray();
for(int i=0;i<100;i++) {
- send("addDocument", "{indexName: index, fields: {id: '" + i + "', value: 'value is " + i + "'}}");
+ send("addDocument", "{fields: {id: '" + i + "', value: 'value is " + i + "'}}");
arr.add("" + i);
}
JSONObject request = new JSONObject();
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestNumericFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestNumericFields.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestNumericFields.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestNumericFields.java Sat Jan 4 12:30:46 2014
@@ -50,8 +50,8 @@ public class TestNumericFields extends S
public void testRetrieve() throws Exception {
deleteAllDocs();
- long gen = getLong(send("addDocument", "{indexName: index, fields: {intNoSort: 17, intSort: 22, floatNoSort: 17.0, floatSort: 22.0}}"), "indexGen");
- JSONObject result = send("search", "{indexName: index, retrieveFields: [intNoSort, intSort, floatNoSort, floatSort], query: MatchAllDocsQuery, searcher: {indexGen: " + gen + "}}");
+ long gen = getLong(send("addDocument", "{fields: {intNoSort: 17, intSort: 22, floatNoSort: 17.0, floatSort: 22.0}}"), "indexGen");
+ JSONObject result = send("search", "{retrieveFields: [intNoSort, intSort, floatNoSort, floatSort], query: MatchAllDocsQuery, searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
assertEquals(17, getInt(result, "hits[0].fields.intNoSort"));
assertEquals(22, getInt(result, "hits[0].fields.intSort"));
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java Sat Jan 4 12:30:46 2014
@@ -76,12 +76,12 @@ public class TestPlugins extends ServerB
// nocommit need a "list plugins" API: verify foobar is there
// nocommit send addDocument & verify change "took"
- send("createIndex", "{indexName: index, rootDir: " + TEST_DIR.getAbsolutePath() + "}");
- send("startIndex", "{indexName: index}");
- send("registerFields", "{indexName: index, fields: {id: {type: int, store: true, postingsFormat: Memory}, intfield: {type: int, store: true}}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {id: 0, mockFoobar: 7}}"), "indexGen");
+ send("createIndex", "{rootDir: " + TEST_DIR.getAbsolutePath() + "}");
+ send("startIndex", "{}");
+ send("registerFields", "{fields: {id: {type: int, store: true, postingsFormat: Memory}, intfield: {type: int, store: true}}}");
+ long gen = getLong(send("addDocument", "{fields: {id: 0, mockFoobar: 7}}"), "indexGen");
- JSONObject result = send("search", "{indexName: index, searcher: {indexGen: " + gen + "}, query: MatchAllDocsQuery, retrieveFields: [id, intfield]}");
+ JSONObject result = send("search", "{searcher: {indexGen: " + gen + "}, query: MatchAllDocsQuery, retrieveFields: [id, intfield]}");
assertEquals(1, getInt(result, "totalHits"));
assertEquals(14, getInt(result, "hits[0].fields.intfield"));
//System.out.println("got: " + prettyPrint(result));
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java Sat Jan 4 12:30:46 2014
@@ -42,6 +42,12 @@ public class TestSearch extends ServerBa
shutdownServer();
}
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ curIndexName = "index";
+ }
+
private static void registerFields() throws Exception {
JSONObject o = new JSONObject();
put(o, "body", "{type: text, highlight: true, store: true, analyzer: {class: WhitespaceAnalyzer, matchVersion: LUCENE_43}, similarity: {class: BM25Similarity, b: 0.15}}");
@@ -49,152 +55,152 @@ public class TestSearch extends ServerBa
put(o, "id", "{type: int, store: true, sort: true}");
JSONObject o2 = new JSONObject();
o2.put("fields", o);
- o2.put("indexName", "index");
send("registerFields", o2);
}
public void testPhraseQuery() throws Exception {
deleteAllDocs();
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'the wizard of oz'}}"), "indexGen");
- JSONObject result = send("search", "{indexName: index, query: {class: PhraseQuery, field: body, terms: [wizard, of, oz]}, searcher: {indexGen: " + gen + "}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'the wizard of oz'}}"), "indexGen");
+ JSONObject result = send("search", "{query: {class: PhraseQuery, field: body, terms: [wizard, of, oz]}, searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
- result = send("search", "{indexName: index, query: {class: PhraseQuery, field: body, terms: [wizard, oz]}, searcher: {indexGen: " + gen + "}}");
+ result = send("search", "{query: {class: PhraseQuery, field: body, terms: [wizard, oz]}, searcher: {indexGen: " + gen + "}}");
assertEquals(0, getInt(result, "totalHits"));
- result = send("search", "{indexName: index, query: {class: PhraseQuery, field: body, terms: [wizard, oz], slop: 1}, searcher: {indexGen: " + gen + "}}");
+ result = send("search", "{query: {class: PhraseQuery, field: body, terms: [wizard, oz], slop: 1}, searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
}
public void testConstantScoreQuery() throws Exception {
deleteAllDocs();
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'the wizard of oz'}}"), "indexGen");
- JSONObject result = send("search", "{indexName: index, query: {class: TermQuery, field: body, term: wizard}, searcher: {indexGen: " + gen + "}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'the wizard of oz'}}"), "indexGen");
+ JSONObject result = send("search", "{query: {class: TermQuery, field: body, term: wizard}, searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
- result = send("search", "{indexName: index, query: {class: ConstantScoreQuery, boost: 10.0, query: {class: TermQuery, field: body, term: wizard}}, searcher: {indexGen: " + gen + "}}");
+ result = send("search", "{query: {class: ConstantScoreQuery, boost: 10.0, query: {class: TermQuery, field: body, term: wizard}}, searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
assertEquals(10.0, getFloat(result, "hits[0].score"), .000001f);
}
public void testRegexpQuery() throws Exception {
deleteAllDocs();
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'testing'}}"), "indexGen");
- JSONObject r = send("search", "{indexName: index, query: {class: RegexpQuery, field: body, regexp: '.*est.*'}, searcher: {indexGen: " + gen + "}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'testing'}}"), "indexGen");
+ JSONObject r = send("search", "{query: {class: RegexpQuery, field: body, regexp: '.*est.*'}, searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(r, "totalHits"));
- r = send("search", "{indexName: index, query: {class: RegexpQuery, field: body, regexp: '.*zest.*'}, searcher: {indexGen: " + gen + "}}");
+ r = send("search", "{query: {class: RegexpQuery, field: body, regexp: '.*zest.*'}, searcher: {indexGen: " + gen + "}}");
assertEquals(0, getInt(r, "totalHits"));
}
public void testTermRangeQuery() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {body: 'terma'}}");
- send("addDocument", "{indexName: index, fields: {body: 'termb'}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'termc'}}"), "indexGen");
+ send("addDocument", "{fields: {body: 'terma'}}");
+ send("addDocument", "{fields: {body: 'termb'}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'termc'}}"), "indexGen");
- JSONObject result = send("search", "{indexName: index, query: {class: TermRangeQuery, field: body, lowerTerm: terma, upperTerm: termc, includeLower: true, includeUpper: true}, searcher: {indexGen: " + gen + "}}");
+ JSONObject result = send("search", "{query: {class: TermRangeQuery, field: body, lowerTerm: terma, upperTerm: termc, includeLower: true, includeUpper: true}, searcher: {indexGen: " + gen + "}}");
assertEquals(3, getInt(result, "totalHits"));
- result = send("search", "{indexName: index, query: {class: TermRangeQuery, field: body, lowerTerm: terma, upperTerm: termc, includeLower: false, includeUpper: false}, searcher: {indexGen: " + gen + "}}");
+ result = send("search", "{query: {class: TermRangeQuery, field: body, lowerTerm: terma, upperTerm: termc, includeLower: false, includeUpper: false}, searcher: {indexGen: " + gen + "}}");
assertEquals(1, getInt(result, "totalHits"));
}
public void testMatchAllDocsQuery() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {body: 'terma'}}");
- send("addDocument", "{indexName: index, fields: {body: 'termb'}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'termc'}}"), "indexGen");
- assertEquals(3, getInt(send("search", "{indexName: index, query: {class: MatchAllDocsQuery}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ send("addDocument", "{fields: {body: 'terma'}}");
+ send("addDocument", "{fields: {body: 'termb'}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'termc'}}"), "indexGen");
+ assertEquals(3, getInt(send("search", "{query: {class: MatchAllDocsQuery}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
public void testWildcardQuery() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {body: 'terma'}}");
- send("addDocument", "{indexName: index, fields: {body: 'termb'}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'termc'}}"), "indexGen");
- assertEquals(3, getInt(send("search", "{indexName: index, query: {class: WildcardQuery, field: body, term: 'term?'}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ send("addDocument", "{fields: {body: 'terma'}}");
+ send("addDocument", "{fields: {body: 'termb'}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'termc'}}"), "indexGen");
+ assertEquals(3, getInt(send("search", "{query: {class: WildcardQuery, field: body, term: 'term?'}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
public void testFuzzyQuery() throws Exception {
deleteAllDocs();
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'fantastic'}}"), "indexGen");
- assertEquals(1, getInt(send("search", "{indexName: index, query: {class: FuzzyQuery, field: body, term: 'fantasic', maxEdits: 1}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(1, getInt(send("search", "{indexName: index, query: {class: FuzzyQuery, field: body, term: 'fantasic', maxEdits: 2}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(0, getInt(send("search", "{indexName: index, query: {class: FuzzyQuery, field: body, term: 'fantasc', maxEdits: 1}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(1, getInt(send("search", "{indexName: index, query: {class: FuzzyQuery, field: body, term: 'fantasc', maxEdits: 2}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(1, getInt(send("search", "{indexName: index, query: {class: FuzzyQuery, field: body, term: 'fantasc', maxEdits: 2, prefixLength: 4}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ long gen = getLong(send("addDocument", "{fields: {body: 'fantastic'}}"), "indexGen");
+ assertEquals(1, getInt(send("search", "{query: {class: FuzzyQuery, field: body, term: 'fantasic', maxEdits: 1}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{query: {class: FuzzyQuery, field: body, term: 'fantasic', maxEdits: 2}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(0, getInt(send("search", "{query: {class: FuzzyQuery, field: body, term: 'fantasc', maxEdits: 1}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{query: {class: FuzzyQuery, field: body, term: 'fantasc', maxEdits: 2}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{query: {class: FuzzyQuery, field: body, term: 'fantasc', maxEdits: 2, prefixLength: 4}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
public void testCommonTermsQuery() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {body: 'fantastic'}}");
- send("addDocument", "{indexName: index, fields: {body: 'fantastic four'}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'fantastic five'}}"), "indexGen");
+ send("addDocument", "{fields: {body: 'fantastic'}}");
+ send("addDocument", "{fields: {body: 'fantastic four'}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'fantastic five'}}"), "indexGen");
- assertEquals(1, getInt(send("search", "{indexName: index, query: {class: CommonTermsQuery, highFreqOccur: must, lowFreqOccur: must, maxTermFrequency: 0.5, field: body, terms: [fantastic, four]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{query: {class: CommonTermsQuery, highFreqOccur: must, lowFreqOccur: must, maxTermFrequency: 0.5, field: body, terms: [fantastic, four]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
public void testMultiPhraseQuery() throws Exception {
deleteAllDocs();
- send("addDocument", "{indexName: index, fields: {body: 'fantastic five is furious'}}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'fantastic four is furious'}}"), "indexGen");
+ send("addDocument", "{fields: {body: 'fantastic five is furious'}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'fantastic four is furious'}}"), "indexGen");
- assertEquals(1, getInt(send("search", "{indexName: index, query: {class: MultiPhraseQuery, field: body, terms: [fantastic, five, is, furious]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(2, getInt(send("search", "{indexName: index, query: {class: MultiPhraseQuery, field: body, terms: [fantastic, {term: furious, position: 3}]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(2, getInt(send("search", "{indexName: index, query: {class: MultiPhraseQuery, field: body, terms: [fantastic, [five, four], {term: furious, position: 3}]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{query: {class: MultiPhraseQuery, field: body, terms: [fantastic, five, is, furious]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(2, getInt(send("search", "{query: {class: MultiPhraseQuery, field: body, terms: [fantastic, {term: furious, position: 3}]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(2, getInt(send("search", "{query: {class: MultiPhraseQuery, field: body, terms: [fantastic, [five, four], {term: furious, position: 3}]}, searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
public void testClassicQPDefaultOperator() throws Exception {
deleteAllDocs();
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'fantastic four is furious'}}"), "indexGen");
+ long gen = getLong(send("addDocument", "{fields: {body: 'fantastic four is furious'}}"), "indexGen");
- assertEquals(1, getInt(send("search", "{indexName: index, queryParser: {class: classic, defaultOperator: or, defaultField: body}, queryText: 'furious five', searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(0, getInt(send("search", "{indexName: index, queryParser: {class: classic, defaultOperator: and, defaultField: body}, queryText: 'furious five', searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{queryParser: {class: classic, defaultOperator: or, defaultField: body}, queryText: 'furious five', searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(0, getInt(send("search", "{queryParser: {class: classic, defaultOperator: and, defaultField: body}, queryText: 'furious five', searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
public void testMultiFieldQP() throws Exception {
deleteAllDocs();
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'fantastic four is furious', title: 'here is the title'}}"), "indexGen");
+ long gen = getLong(send("addDocument", "{fields: {body: 'fantastic four is furious', title: 'here is the title'}}"), "indexGen");
- assertEquals(1, getInt(send("search", "{indexName: index, queryParser: {class: MultiFieldQueryParser, defaultOperator: or, fields: [body, {field: title, boost: 2.0}]}, queryText: 'title furious', searcher: {indexGen: " + gen + "}}"), "totalHits"));
- assertEquals(1, getInt(send("search", "{indexName: index, queryParser: {class: MultiFieldQueryParser, defaultOperator: and, fields: [body, {field: title, boost: 2.0}]}, queryText: 'title furious', searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{queryParser: {class: MultiFieldQueryParser, defaultOperator: or, fields: [body, {field: title, boost: 2.0}]}, queryText: 'title furious', searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ assertEquals(1, getInt(send("search", "{queryParser: {class: MultiFieldQueryParser, defaultOperator: and, fields: [body, {field: title, boost: 2.0}]}, queryText: 'title furious', searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
public void testNumericRangeQuery() throws Exception {
+ curIndexName = "nrq";
for(String type : new String[] {"int", "long", "float", "double"}) {
- send("createIndex", "{indexName: nrq, rootDir: nrq}");
- send("startIndex", "{indexName: nrq}");
- send("registerFields", String.format(Locale.ROOT, "{indexName: nrq, fields: {nf: {type: %s, index: true}}}", type));
- send("addDocument", "{indexName: nrq, fields: {nf: 5}}");
- send("addDocument", "{indexName: nrq, fields: {nf: 10}}");
- long gen = getLong(send("addDocument", "{indexName: nrq, fields: {nf: 17}}"), "indexGen");
+ send("createIndex", "{rootDir: nrq}");
+ send("startIndex", "{}");
+ send("registerFields", String.format(Locale.ROOT, "{fields: {nf: {type: %s, index: true}}}", type));
+ send("addDocument", "{fields: {nf: 5}}");
+ send("addDocument", "{fields: {nf: 10}}");
+ long gen = getLong(send("addDocument", "{fields: {nf: 17}}"), "indexGen");
// Both min & max:
assertEquals(3, getInt(send("search",
- String.format(Locale.ROOT, "{indexName: nrq, query: {class: NumericRangeQuery, field: nf, min: 5, max: 17, minInclusive: true, maxInclusive: true}, searcher: {indexGen: %d}}", gen)),
+ String.format(Locale.ROOT, "{query: {class: NumericRangeQuery, field: nf, min: 5, max: 17, minInclusive: true, maxInclusive: true}, searcher: {indexGen: %d}}", gen)),
"totalHits"));
// Leave min out:
assertEquals(3, getInt(send("search",
- String.format(Locale.ROOT, "{indexName: nrq, query: {class: NumericRangeQuery, field: nf, max: 17, maxInclusive: true}, searcher: {indexGen: %d}}", gen)),
+ String.format(Locale.ROOT, "{query: {class: NumericRangeQuery, field: nf, max: 17, maxInclusive: true}, searcher: {indexGen: %d}}", gen)),
"totalHits"));
// Leave min out, don't include max:
assertEquals(2, getInt(send("search",
- String.format(Locale.ROOT, "{indexName: nrq, query: {class: NumericRangeQuery, field: nf, max: 17, maxInclusive: false}, searcher: {indexGen: %d}}", gen)),
+ String.format(Locale.ROOT, "{query: {class: NumericRangeQuery, field: nf, max: 17, maxInclusive: false}, searcher: {indexGen: %d}}", gen)),
"totalHits"));
// Leave max out:
assertEquals(3, getInt(send("search",
- String.format(Locale.ROOT, "{indexName: nrq, query: {class: NumericRangeQuery, field: nf, min: 5, minInclusive: true}, searcher: {indexGen: %d}}", gen)),
+ String.format(Locale.ROOT, "{query: {class: NumericRangeQuery, field: nf, min: 5, minInclusive: true}, searcher: {indexGen: %d}}", gen)),
"totalHits"));
// Leave max out, don't include max:
assertEquals(2, getInt(send("search",
- String.format(Locale.ROOT, "{indexName: nrq, query: {class: NumericRangeQuery, field: nf, min: 5, minInclusive: false}, searcher: {indexGen: %d}}", gen)),
+ String.format(Locale.ROOT, "{query: {class: NumericRangeQuery, field: nf, min: 5, minInclusive: false}, searcher: {indexGen: %d}}", gen)),
"totalHits"));
- send("stopIndex", "{indexName: nrq}");
- send("deleteIndex", "{indexName: nrq}");
+ send("stopIndex", "{}");
+ send("deleteIndex", "{}");
}
}
@@ -202,7 +208,7 @@ public class TestSearch extends ServerBa
deleteAllDocs();
long gen = 0;
for(int i=0;i<20;i++) {
- gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'this is the body', id: " + i + "}}"), "indexGen");
+ gen = getLong(send("addDocument", "{fields: {body: 'this is the body', id: " + i + "}}"), "indexGen");
}
JSONObject lastPage = null;
@@ -218,7 +224,7 @@ public class TestSearch extends ServerBa
sa = "";
}
- lastPage = send("search", "{indexName: index, query: MatchAllDocsQuery, topHits: 5, retrieveFields: [id], searcher: {indexGen: " + gen + "}" + sa + "}");
+ lastPage = send("search", "{query: MatchAllDocsQuery, topHits: 5, retrieveFields: [id], searcher: {indexGen: " + gen + "}" + sa + "}");
//System.out.println("i=" + i + ": " + lastPage);
// 20 total hits
@@ -236,7 +242,7 @@ public class TestSearch extends ServerBa
deleteAllDocs();
long gen = 0;
for(int i=0;i<20;i++) {
- gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'this is the body', id: " + i + "}}"), "indexGen");
+ gen = getLong(send("addDocument", "{fields: {body: 'this is the body', id: " + i + "}}"), "indexGen");
}
JSONObject lastPage = null;
@@ -247,7 +253,6 @@ public class TestSearch extends ServerBa
for(int i=0;i<4;i++) {
String sa;
JSONObject o = new JSONObject();
- o.put("indexName", "index");
o.put("query", "MatchAllDocsQuery");
o.put("topHits", 5);
put(o, "retrieveFields", "[id]");
@@ -276,31 +281,32 @@ public class TestSearch extends ServerBa
}
public void testRecencyBlendedSort() throws Exception {
+ curIndexName = "recency";
File dir = new File(_TestUtil.getTempDir("recency"), "root");
- send("createIndex", "{indexName: recency, rootDir: " + dir.getAbsolutePath() + "}");
- send("startIndex", "{indexName: recency}");
- send("registerFields", "{indexName: recency, fields: {timestamp: {type: long, index: false, sort: true}, body: {type: text, analyzer: StandardAnalyzer}, blend: {type: virtual, recencyScoreBlend: {timeStampField: timestamp, maxBoost: 2.0, range: 30}}}}");
+ send("createIndex", "{rootDir: " + dir.getAbsolutePath() + "}");
+ send("startIndex", "{}");
+ send("registerFields", "{fields: {timestamp: {type: long, index: false, sort: true}, body: {type: text, analyzer: StandardAnalyzer}, blend: {type: virtual, recencyScoreBlend: {timeStampField: timestamp, maxBoost: 2.0, range: 30}}}}");
long t = System.currentTimeMillis()/1000;
- send("addDocument", "{indexName: recency, fields: {body: 'this is some text', timestamp: " + (t-100) + "}}");
- long gen = getLong(send("addDocument", "{indexName: recency, fields: {body: 'this is some text', timestamp: " + t + "}}"), "indexGen");
+ send("addDocument", "{fields: {body: 'this is some text', timestamp: " + (t-100) + "}}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'this is some text', timestamp: " + t + "}}"), "indexGen");
for(int pass=0;pass<2;pass++) {
// Unboosted:
- JSONObject result = send("search", "{indexName: recency, queryText: text, searcher: {indexGen: " + gen + "}}");
+ JSONObject result = send("search", "{queryText: text, searcher: {indexGen: " + gen + "}}");
assertEquals(2, getInt(result, "totalHits"));
assertEquals(0, getInt(result, "hits[0].doc"));
assertEquals(1, getInt(result, "hits[1].doc"));
// Relevance + recency changes the order:
- result = send("search", "{indexName: recency, queryText: text, sort: {fields: [{field: blend}]}, searcher: {indexGen: " + gen + "}}");
+ result = send("search", "{queryText: text, sort: {fields: [{field: blend}]}, searcher: {indexGen: " + gen + "}}");
assertEquals(2, getInt(result, "totalHits"));
assertEquals(1, getInt(result, "hits[0].doc"));
assertEquals(0, getInt(result, "hits[1].doc"));
// Make sure this survives restart:
- send("stopIndex", "{indexName: recency}");
- send("startIndex", "{indexName: recency}");
+ send("stopIndex", "{}");
+ send("startIndex", "{}");
}
}
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestServer.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestServer.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestServer.java Sat Jan 4 12:30:46 2014
@@ -245,13 +245,13 @@ public class TestServer extends ServerBa
public void testMultiValuedString() throws Exception {
deleteAllDocs();
- send("registerFields", "{indexName: index, fields: {authors: {type: text, index: true, store: true, facet: flat, multiValued: true, analyzer: {matchVersion: LUCENE_43, class: StandardAnalyzer}}}}");
+ send("registerFields", "{fields: {authors: {type: text, index: true, store: true, facet: flat, multiValued: true, analyzer: {matchVersion: LUCENE_43, class: StandardAnalyzer}}}}");
- JSONObject result = send("addDocument", "{indexName: index, fields: {authors: [Bob, Lisa]}}");
+ JSONObject result = send("addDocument", "{fields: {authors: [Bob, Lisa]}}");
long indexGen = getInt(result, "indexGen");
- result = send("search", "{indexName: index, searcher: {indexGen: " + indexGen + "}, queryText: 'authors:bob', retrieveFields: [authors]}");
+ result = send("search", "{searcher: {indexGen: " + indexGen + "}, queryText: 'authors:bob', retrieveFields: [authors]}");
assertEquals(1, getInt(result, "totalHits"));
assertEquals("[\"Bob\",\"Lisa\"]", getArray(result, "hits[0].fields.authors").toString());
@@ -260,13 +260,13 @@ public class TestServer extends ServerBa
public void testMultiValuedNumeric() throws Exception {
deleteAllDocs();
- send("registerFields", "{indexName: index, fields: {ratings: {type: int, index: true, store: true, multiValued: true}}}");
+ send("registerFields", "{fields: {ratings: {type: int, index: true, store: true, multiValued: true}}}");
- JSONObject result = send("addDocument", "{indexName: index, fields: {body: 'here is a test', ratings: [17, 22]}}");
+ JSONObject result = send("addDocument", "{fields: {body: 'here is a test', ratings: [17, 22]}}");
long indexGen = getInt(result, "indexGen");
- result = send("search", "{indexName: index, searcher: {indexGen: " + indexGen + "}, queryText: 'body:test', retrieveFields: [ratings]}");
+ result = send("search", "{searcher: {indexGen: " + indexGen + "}, queryText: 'body:test', retrieveFields: [ratings]}");
assertEquals(1, getInt(result, "totalHits"));
assertEquals("[17,22]", getArray(result, "hits[0].fields.ratings").toString());
@@ -275,47 +275,47 @@ public class TestServer extends ServerBa
public void testStandardAnalyzer() throws Exception {
deleteAllDocs();
- send("registerFields", "{indexName: index, fields: {aTextField: {type: text, analyzer: {class: StandardAnalyzer, matchVersion: LUCENE_43}, store: true}}}");
+ send("registerFields", "{fields: {aTextField: {type: text, analyzer: {class: StandardAnalyzer, matchVersion: LUCENE_43}, store: true}}}");
- JSONObject result = send("addDocument", "{indexName: index, fields: {aTextField: 'here is a test'}}");
+ JSONObject result = send("addDocument", "{fields: {aTextField: 'here is a test'}}");
long indexGen = getInt(result, "indexGen");
// nocommit: grrr need QP to understand schema
//o.put("queryText", "ratings:[16 TO 18]");
// search on a stop word should yield no results:
- result = send("search", String.format(Locale.ROOT, "{indexName: index, searcher: {indexGen: %d}, queryText: 'aTextField:a'}", indexGen));
+ result = send("search", String.format(Locale.ROOT, "{searcher: {indexGen: %d}, queryText: 'aTextField:a'}", indexGen));
assertEquals(0, getInt(result, "totalHits"));
}
public void testStandardAnalyzerNoStopWords() throws Exception {
deleteAllDocs();
- send("registerFields", "{indexName: index, fields: {aTextField2: {type: text, index: true, store: true, analyzer: {class: StandardAnalyzer, matchVersion: LUCENE_43, stopWords: []}}}}");
+ send("registerFields", "{fields: {aTextField2: {type: text, index: true, store: true, analyzer: {class: StandardAnalyzer, matchVersion: LUCENE_43, stopWords: []}}}}");
- JSONObject result = send("addDocument", "{indexName: index, fields: {aTextField2: 'here is a test'}}");
+ JSONObject result = send("addDocument", "{fields: {aTextField2: 'here is a test'}}");
long indexGen = getLong(result, "indexGen");
// nocommit: grrr need QP to understand schema
//o.put("queryText", "ratings:[16 TO 18]");
// search on a stop word should now yield one hit:
- result = send("search", "{indexName: index, queryText: 'aTextField2:a', searcher: {indexGen: " + indexGen + "}}");
+ result = send("search", "{queryText: 'aTextField2:a', searcher: {indexGen: " + indexGen + "}}");
assertEquals(1, getInt(result, "totalHits"));
}
public void testEnglishAnalyzerNoStopWords() throws Exception {
deleteAllDocs();
- send("registerFields", "{indexName: index, fields: {aTextField3: {type: text, index: true, store: true, analyzer: {class: EnglishAnalyzer, matchVersion: LUCENE_43, stopWords: []}}}}");
- JSONObject result = send("addDocument", "{indexName: index, fields: {aTextField3: 'the cats in the hat'}}");
+ send("registerFields", "{fields: {aTextField3: {type: text, index: true, store: true, analyzer: {class: EnglishAnalyzer, matchVersion: LUCENE_43, stopWords: []}}}}");
+ JSONObject result = send("addDocument", "{fields: {aTextField3: 'the cats in the hat'}}");
long indexGen = getLong(result, "indexGen");
// nocommit: grrr need QP to understand schema
//o.put("queryText", "ratings:[16 TO 18]");
// cats should stem to cat and get a match:
- result = send("search", "{indexName: index, queryText: 'aTextField3:cat', searcher: {indexGen: " + indexGen + "}}");
+ result = send("search", "{queryText: 'aTextField3:cat', searcher: {indexGen: " + indexGen + "}}");
assertEquals(1, getInt(result, "totalHits"));
}
@@ -351,16 +351,16 @@ public class TestServer extends ServerBa
public void testServerRestart() throws Exception {
deleteAllDocs();
addDocument(0, "Bob", "this is a test", 10f, "2012/10/17");
- send("commit", "{indexName: index}");
+ send("commit", "{}");
shutdownServer();
startServer();
- send("startIndex", "{indexName: index}");
+ send("startIndex", "{}");
JSONObject o = search("test", 0, null, false, true, null, null);
assertEquals(1, ((Number) o.get("totalHits")).intValue());
}
public void testStatsHandler() throws Exception {
- JSONObject result = send("stats", "{indexName: index}");
+ JSONObject result = send("stats", "{}");
//System.out.println("GOT: " + result);
}
Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSettings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSettings.java?rev=1555341&r1=1555340&r2=1555341&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSettings.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSettings.java Sat Jan 4 12:30:46 2014
@@ -37,21 +37,21 @@ public class TestSettings extends Server
}
private static void registerFields() throws Exception {
- send("registerFields", "{indexName: index, fields: {body: {type: text, analyzer: StandardAnalyzer}}}");
+ send("registerFields", "{fields: {body: {type: text, analyzer: StandardAnalyzer}}}");
}
public void testNRTCachingDirSettings() throws Exception {
deleteAllDocs();
commit();
- send("stopIndex", "{indexName: index}");
- JSONObject o = send("settings", "{indexName: index}");
+ send("stopIndex", "{}");
+ JSONObject o = send("settings", "{}");
assertEquals(0, o.size());
// Turn off NRTCachingDir:
- send("settings", "{indexName: index, nrtCachingDirectory.maxMergeSizeMB: 0.0, nrtCachingDirectory.maxSizeMB: 0.0}");
- o = send("settings", "{indexName: index}");
+ send("settings", "{nrtCachingDirectory.maxMergeSizeMB: 0.0, nrtCachingDirectory.maxSizeMB: 0.0}");
+ o = send("settings", "{}");
assertEquals(2, o.size());
- send("startIndex", "{indexName: index}");
- long gen = getLong(send("addDocument", "{indexName: index, fields: {body: 'here is a test'}}"), "indexGen");
- assertEquals(1, getInt(send("search", "{indexName: index, queryText: test, searcher: {indexGen: " + gen + "}}"), "totalHits"));
+ send("startIndex", "{}");
+ long gen = getLong(send("addDocument", "{fields: {body: 'here is a test'}}"), "indexGen");
+ assertEquals(1, getInt(send("search", "{queryText: test, searcher: {indexGen: " + gen + "}}"), "totalHits"));
}
}