org.apache.solr.util.TestHarness Java Examples
The following examples show how to use
org.apache.solr.util.TestHarness.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testTermVecMultiValuedHighlight2() throws Exception { // do summarization using term vectors on multivalued field HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_mv_text"); args.put("hl.snippets", "2"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "",0,200,args); String shortText = "short"; assertU(adoc("tv_mv_text", shortText, "tv_mv_text", LONG_TEXT, "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("tv_mv_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_mv_text']/str[.='a <em>long</em> days night this should be a piece of text which']", "//arr[@name='tv_mv_text']/str[.=' <em>long</em> fragments.']" ); }
Example #2
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testMultiValueAnalysisHighlight() { // do summarization using re-analysis of the field HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "textgap"); args.put("df", "textgap"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("textgap", "first entry hasnt queryword", "textgap", "second entry has queryword long", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='textgap']/str" ); }
Example #3
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testMultiValueBestFragmentHighlight() { HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "textgap"); args.put("df", "textgap"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("textgap", "first entry has one word foo", "textgap", "second entry has both words foo bar", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Best fragment summarization", sumLRF.makeRequest("foo bar"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='textgap']/str[.=\'second entry has both words <em>foo</em> <em>bar</em>\']" ); }
Example #4
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testDefaultFieldHighlight() { // do summarization using re-analysis of the field HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("df", "t_text"); args.put("hl.fl", ""); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("t_text", "a long day's night", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='t_text']/str" ); }
Example #5
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testHighlightDisabled() { // ensure highlighting can be explicitly disabled HashMap<String,String> args = new HashMap<>(); args.put("hl", "false"); args.put("hl.fl", "t_text"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("t_text", "a long day's night", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("t_text:long"), "not(//lst[@name='highlighting'])"); }
Example #6
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testTwoFieldHighlight() { // do summarization using re-analysis of the field HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "t_text tv_text"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("t_text", "a long day's night", "id", "1", "tv_text", "a long night's day")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("t_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='t_text']/str", "//lst[@name='1']/arr[@name='tv_text']/str" ); }
Example #7
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testTermVecHighlight() { // do summarization using term vectors HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_text"); args.put("hl.snippets", "2"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "",0,200,args); assertU(adoc("tv_text", LONG_TEXT, "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("tv_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_text']/str[.='a <em>long</em> days night this should be a piece of text which']", "//arr[@name='tv_text']/str[.=' <em>long</em> fragments.']" ); }
Example #8
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testLongFragment() { HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_text"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); String text = "junit: [mkdir] Created dir: /home/klaas/worio/backend/trunk/build-src/solr-nightly/build/test-results [junit] Running org.apache.solr.BasicFunctionalityTest [junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 5.36 sec [junit] Running org.apache.solr.ConvertedLegacyTest [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 8.268 sec [junit] Running org.apache.solr.DisMaxRequestHandlerTest [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.56 sec [junit] Running org.apache.solr.HighlighterTest [junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 4.979 sec [junit] Running org.apache.solr.OutputWriterTest [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.797 sec [junit] Running org.apache.solr.SampleTest [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 1.021 sec [junit] Running org.apache.solr.analysis.TestBufferedTokenStream [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.05 sec [junit] Running org.apache.solr.analysis.TestRemoveDuplicatesTokenFilter [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.054 sec [junit] Running org.apache.solr.analysis.TestSynonymFilter [junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 0.081 sec [junit] Running org.apache.solr.analysis.TestWordDelimiterFilter [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.714 sec [junit] Running org.apache.solr.search.TestDocSet [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.788 sec [junit] Running org.apache.solr.util.SolrPluginUtilsTest [junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 3.519 sec [junit] Running org.apache.solr.util.TestOpenBitSet [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.533 sec"; assertU(adoc("tv_text", text, "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("tv_text:dir"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_text']/str" ); }
Example #9
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testTermVectorWithoutOffsetsHighlight() { HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_no_off_text"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory("", 0, 200, args); assertU(adoc("tv_no_off_text", "Crackerjack Cameron", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Fields with term vectors switched on but no offsets should be correctly highlighted", sumLRF.makeRequest("tv_no_off_text:cameron"), "//arr[@name='tv_no_off_text']/str[.='Crackerjack <em>Cameron</em>']"); }
Example #10
Source File: LukeRequestHandlerTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testCatchAllCopyField() throws Exception { deleteCore(); initCore("solrconfig.xml", "schema-copyfield-test.xml"); IndexSchema schema = h.getCore().getLatestSchema(); assertNull("'*' should not be (or match) a dynamic field", schema.getDynamicPattern("*")); boolean foundCatchAllCopyField = false; for (IndexSchema.DynamicCopy dcf : schema.getDynamicCopyFields()) { foundCatchAllCopyField = dcf.getRegex().equals("*") && dcf.getDestFieldName().equals("catchall_t"); if (foundCatchAllCopyField) { break; } } assertTrue("<copyField source=\"*\" dest=\"catchall_t\"/> is missing from the schema", foundCatchAllCopyField); SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema", "indent", "on"); String xml = h.query(req); String result = TestHarness.validateXPath(xml, field("bday") + "/arr[@name='copyDests']/str[.='catchall_t']"); assertNull(xml, result); // Put back the configuration expected by the rest of the tests in this suite deleteCore(); initCore("solrconfig.xml", "schema12.xml"); }
Example #11
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testDefaultFieldPrefixWildcardHighlight() { // do summarization using re-analysis of the field HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("df", "t_text"); args.put("hl.fl", ""); args.put("hl.usePhraseHighlighter", "true"); args.put("hl.highlightMultiTerm", "true"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("t_text", "a long day's night", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("lon*"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='t_text']/str" ); }
Example #12
Source File: SolrTestCaseHS.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Pass "null" for the client to query to the local server. * Fetches response in xml format and matches with the given set of xpaths */ public static void assertQ(SolrClient client, SolrParams args, String... tests) throws Exception { String resp; resp = getQueryResponse(client, "xml", args); try { String results = TestHarness.validateXPath(resp, tests); if (null != results) { String msg = "REQUEST FAILED: xpath=" + results + "\n\txml response was: " + resp + "\n\tparams were:" + args.toQueryString(); log.error(msg); throw new RuntimeException(msg); } } catch (XPathExpressionException e1) { throw new RuntimeException("XPath is invalid", e1); } catch (Exception e2) { SolrException.log(log,"REQUEST FAILED for params: " + args.toQueryString(), e2); throw new RuntimeException("Exception during query", e2); } }
Example #13
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testDefaultFieldNonPrefixWildcardHighlight() { // do summarization using re-analysis of the field HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("df", "t_text"); args.put("hl.fl", ""); args.put("hl.usePhraseHighlighter", "true"); args.put("hl.highlightMultiTerm", "true"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("t_text", "a long day's night", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("l*g"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='t_text']/str" ); }
Example #14
Source File: HighlighterConfigTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testConfig() { SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore()); log.info( "highlighter" ); assertTrue( highlighter instanceof DummyHighlighter ); // check to see that doHighlight is called from the DummyHighlighter HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("df", "t_text"); args.put("hl.fl", ""); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("t_text", "a long day's night", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("long"), "//lst[@name='highlighting']/str[@name='dummy']" ); }
Example #15
Source File: FastVectorHighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void test() { HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_text"); args.put("hl.snippets", "2"); args.put("hl.tag.pre", "<fvpre>"); //... and let post default to </em>. This is just a test. if (random().nextBoolean()) { args.put("hl.useFastVectorHighlighter", "true"); // old way } else { args.put("hl.method", "fastVector"); // the new way } TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "",0,200,args); assertU(adoc("tv_text", "basic fast vector highlighter test", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("tv_text:vector"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_text']/str[.='basic fast <fvpre>vector</em> highlighter test']" ); }
Example #16
Source File: RankFieldTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testScoreChanges() throws Exception { assertU(adoc( "id", "1", "str_field", "foo", RANK_1, "1" )); assertU(commit()); ModifiableSolrParams params = params("q", "foo", "defType", "dismax", "qf", "str_field^10", "fl", "id,score", "wt", "xml"); double scoreBefore = (Double) TestHarness.evaluateXPath(h.query(req(params)), "//result/doc[1]/float[@name='score']", XPathConstants.NUMBER); params.add("bq", "{!rank f='" + RANK_1 + "' function='log' scalingFactor='1'}"); double scoreAfter = (Double) TestHarness.evaluateXPath(h.query(req(params)), "//result/doc[1]/float[@name='score']", XPathConstants.NUMBER); assertNotEquals("Expecting score to change", scoreBefore, scoreAfter, 0f); }
Example #17
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testTermVecMultiValuedHighlight() throws Exception { // do summarization using term vectors on multivalued field HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_mv_text"); args.put("hl.snippets", "2"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "",0,200,args); assertU(adoc("tv_mv_text", LONG_TEXT, "tv_mv_text", LONG_TEXT, "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("tv_mv_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_mv_text']/str[.='a <em>long</em> days night this should be a piece of text which']", "//arr[@name='tv_mv_text']/str[.=' <em>long</em> fragments.']" ); }
Example #18
Source File: UninvertDocValuesMergePolicyTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private static void withNewRawReader(TestHarness h, DirectoryReaderConsumer consumer) { try (SolrCore core = h.getCoreInc()) { final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true); final SolrIndexSearcher searcher = searcherRef.get(); try { try { consumer.accept(searcher.getRawReader()); } catch (Exception e) { fail(e.toString()); } } finally { searcherRef.decref(); } } }
Example #19
Source File: LukeRequestHandlerTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testCopyFieldLists() throws Exception { SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema"); String xml = h.query(req); String r = TestHarness.validateXPath (xml, field("text") + "/arr[@name='copySources']/str[.='title']", field("text") + "/arr[@name='copySources']/str[.='subject']", field("title") + "/arr[@name='copyDests']/str[.='text']", field("title") + "/arr[@name='copyDests']/str[.='title_stemmed']", dynfield("bar_copydest_*") + "/arr[@name='copySources']/str[.='foo_copysource_*']", dynfield("foo_copysource_*") + "/arr[@name='copyDests']/str[.='bar_copydest_*']"); assertEquals(xml, null, r); }
Example #20
Source File: UninvertDocValuesMergePolicyTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private static void implUpdateSchemaField(TestHarness h, String fieldName, IntUnaryOperator propertiesModifier) { try (SolrCore core = h.getCoreInc()) { // Add docvalues to the field type IndexSchema schema = core.getLatestSchema(); SchemaField oldSchemaField = schema.getField(fieldName); SchemaField newSchemaField = new SchemaField( fieldName, oldSchemaField.getType(), propertiesModifier.applyAsInt(oldSchemaField.getProperties()), oldSchemaField.getDefaultValue()); schema.getFields().put(fieldName, newSchemaField); } }
Example #21
Source File: AbstractAlfrescoSolrIT.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
/** * @deprecated as testHarness is used * Creates a Solr Alfresco test harness. * @param schema * @throws Exception */ @Deprecated public static void initAlfrescoCore(String schema) throws Exception { LOG.info("##################################### init Alfresco core ##############"); LOG.info("####initCore"); System.setProperty("solr.solr.home", TEST_FILES_LOCATION); System.setProperty("solr.directoryFactory","solr.RAMDirectoryFactory"); System.setProperty("solr.tests.maxBufferedDocs", "1000"); System.setProperty("solr.tests.maxIndexingThreads", "10"); System.setProperty("solr.tests.ramBufferSizeMB", "1024"); // other methods like starting a jetty instance need these too System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop2", "proptwo"); System.setProperty("alfresco.test", "true"); System.setProperty("solr.tests.mergeScheduler", "org.apache.lucene.index.ConcurrentMergeScheduler"); System.setProperty("solr.tests.mergePolicy", "org.apache.lucene.index.TieredMergePolicy"); if (CORE_NOT_YET_CREATED) { testExecutionSolrHome = TEST_EXECUTION_FOLDER + "/" + Time.now() + "/solrhome"; testSolrCollection = testExecutionSolrHome + "/collection1"; testSolrConf = testSolrCollection + "/conf/"; templateConf = testExecutionSolrHome + "/templates/%s/conf/"; copyTestFiles(); createAlfrescoCore(schema); } LOG.info("####initCore end"); admin = of(h).map(TestHarness::getCoreContainer) .map(CoreContainer::getMultiCoreHandler) .map(AlfrescoCoreAdminHandler.class::cast) .orElseThrow(RuntimeException::new); }
Example #22
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testDisMaxHighlight() { // same test run through dismax handler HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_text"); args.put("qf", "tv_text"); args.put("q.alt", "*:*"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "/dismax",0,200,args); assertU(adoc("tv_text", "a long day's night", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_text']/str" ); // try the same thing without a q param assertQ("Should not explode...", // q.alt should return everything sumLRF.makeRequest( new String[] { null } ), // empty query "//result[@numFound='1']" ); }
Example #23
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testCustomSimpleFormatterHighlight() { // do summarization using a custom formatter HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "t_text"); args.put("hl.simple.pre","<B>"); args.put("hl.simple.post", "</B>"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc("t_text", "a long days night", "id", "1")); assertU(commit()); assertU(optimize()); assertQ("Basic summarization", sumLRF.makeRequest("t_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='t_text']/str[.='a <B>long</B> days night']" ); // test a per-field override args.put("f.t_text.hl.simple.pre", "<I>"); args.put("f.t_text.hl.simple.post", "</I>"); sumLRF = h.getRequestFactory( "", 0, 200, args); assertQ("Basic summarization", sumLRF.makeRequest("t_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='t_text']/str[.='a <I>long</I> days night']" ); }
Example #24
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testMaxChars() { HashMap<String,String> args = new HashMap<>(); args.put("fl", "id score"); args.put("hl", "true"); args.put("hl.snippets", "10"); final String field = random().nextBoolean() ? "t_text" : "tv_text"; args.put("hl.fl", field); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertU(adoc(field, LONG_TEXT, "id", "1")); assertU(commit()); assertQ("token at start of text", sumLRF.makeRequest(field + ":disjoint"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[count(str)=1]" ); args.put("hl.maxAnalyzedChars", "20"); sumLRF = h.getRequestFactory("", 0, 200, args); assertQ("token at end of text", sumLRF.makeRequest(field + ":disjoint"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1'][not(*)]" ); args.put("hl.maxAnalyzedChars", "-1"); sumLRF = h.getRequestFactory("", 0, 200, args); assertQ("token at start of text", sumLRF.makeRequest(field + ":disjoint"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[count(str)=1]" ); }
Example #25
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testRegexFragmenter() { HashMap<String,String> args = new HashMap<>(); args.put("fl", "id score"); args.put("hl", "true"); args.put("hl.snippets", "10"); args.put("hl.fl", "t_text"); args.put("hl.fragmenter", "regex"); args.put("hl.regex.pattern", "[-\\w ,\"']{20,200}"); args.put("hl.regex.slop", ".9"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); String t = "This is an example of a sentence. Another example \"sentence\" with " + "special characters\nand a line-break! Miscellaneous character like ^ are " + "unknowns and end up being bad example s of sentences? I wonder how " + "slashes/other punctuation fare in these examples?"; assertU(adoc("t_text", t, "id", "1")); assertU(commit()); assertU(optimize()); assertQ("regex fragmenter", sumLRF.makeRequest("t_text:example"), "//lst[@name='highlighting']/lst[@name='1']", "//arr/str[.='This is an <em>example</em> of a sentence']", "//arr/str[.='. Another <em>example</em> \"sentence\" with special characters\nand a line-break']", "//arr/str[.=' ^ are unknowns and end up being bad <em>example</em> s of sentences']", "//arr/str[.='/other punctuation fare in these <em>examples</em>?']" ); // try with some punctuation included args.put("hl.regex.pattern", "[-\\w ,^/\\n\"']{20,200}"); sumLRF = h.getRequestFactory("", 0, 200, args); assertQ("regex fragmenter 2", sumLRF.makeRequest("t_text:example"), "//lst[@name='highlighting']/lst[@name='1']", "//arr/str[.='This is an <em>example</em> of a sentence']", "//arr/str[.='. Another <em>example</em> \"sentence\" with special characters\nand a line-break']", "//arr/str[.='! Miscellaneous character like ^ are unknowns and end up being bad <em>example</em> s of sentences']", "//arr/str[.='? I wonder how slashes/other punctuation fare in these <em>examples</em>?']" ); }
Example #26
Source File: HighlighterTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testVariableFragsize() { assertU(adoc("tv_text", "a long days night this should be a piece of text which is is is is is is is is is is is is is is is is is is is is is is is is isis is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is sufficiently lengthly to produce multiple fragments which are not concatenated at all", "id", "1")); assertU(commit()); assertU(optimize()); // default length HashMap<String,String> args = new HashMap<>(); args.put("hl", "true"); args.put("hl.fl", "tv_text"); TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory( "", 0, 200, args); assertQ("Basic summarization", sumLRF.makeRequest("tv_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_text']/str[.='a <em>long</em> days night this should be a piece of text which']" ); // 25 args.put("hl.fragsize","25"); sumLRF = h.getRequestFactory( "", 0, 200, args); assertQ("Basic summarization", sumLRF.makeRequest("tv_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_text']/str[.='a <em>long</em> days night']" ); // 0 - NullFragmenter args.put("hl.fragsize","0"); sumLRF = h.getRequestFactory( "", 0, 200, args); assertQ("Basic summarization", sumLRF.makeRequest("tv_text:long"), "//lst[@name='highlighting']/lst[@name='1']", "//lst[@name='1']/arr[@name='tv_text']/str[.='a <em>long</em> days night this should be a piece of text which is is is is is is is is is is is is is is is is is is is is is is is is isis is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is is sufficiently lengthly to produce multiple fragments which are not concatenated at all']" ); }
Example #27
Source File: TestCodecSupport.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testCompressionModeDefault() throws IOException { assertEquals("Default Solr compression mode changed. Is this expected?", SchemaCodecFactory.SOLR_DEFAULT_COMPRESSION_MODE, Mode.valueOf("BEST_SPEED")); String previousCoreName = h.coreName; String newCoreName = "core_with_default_compression"; SolrCore c = null; SolrConfig config = TestHarness.createConfig(testSolrHome, previousCoreName, "solrconfig_codec2.xml"); assertEquals("Unexpected codec factory for this test.", "solr.SchemaCodecFactory", config.get("codecFactory/@class")); assertNull("Unexpected configuration of codec factory for this test. Expecting empty element", config.getNode("codecFactory", false).getFirstChild()); IndexSchema schema = IndexSchemaFactory.buildIndexSchema("schema_codec.xml", config); CoreContainer coreContainer = h.getCoreContainer(); try { CoreDescriptor cd = new CoreDescriptor(newCoreName, testSolrHome.resolve(newCoreName), coreContainer); c = new SolrCore(coreContainer, cd, new ConfigSet("fakeConfigset", config, schema, null, true)); assertNull(coreContainer.registerCore(cd, c, false, false)); h.coreName = newCoreName; assertEquals("We are not using the correct core", "solrconfig_codec2.xml", h.getCore().getConfigResource()); assertU(add(doc("string_f", "foo"))); assertU(commit()); assertCompressionMode(SchemaCodecFactory.SOLR_DEFAULT_COMPRESSION_MODE.name(), h.getCore()); } finally { h.coreName = previousCoreName; coreContainer.unload(newCoreName); } }
Example #28
Source File: TestDataProvider.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
public TestDataProvider(final TestHarness testHarness) throws Exception { this.core = testHarness.getCore(); dataModel.getNamespaceDAO().removePrefix(""); dataModel.setCMDefaultUri(); rootNodeRef = newNodeRef(); addStoreRoot(core, dataModel, rootNodeRef, 1, 1, 1, 1); }
Example #29
Source File: LukeRequestHandlerTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testIndexHeapUsageBytes() throws Exception { try (SolrQueryRequest req = req("qt", "/admin/luke")) { String response = h.query(req); String xpath = "//long[@name='indexHeapUsageBytes']"; Double num = (Double) TestHarness.evaluateXPath(response, xpath, XPathConstants.NUMBER); //with docs in the index, indexHeapUsageBytes should be greater than 0 Assert.assertTrue("indexHeapUsageBytes should be > 0, but was " + num.intValue(), num.intValue() > 0); } }
Example #30
Source File: AbstractAlfrescoSolrIT.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
/** * Generates a simple <doc>... XML String with no options * * @param fieldsAndValues 0th and Even numbered args are fields names, Odds are field values. * @see TestHarness#makeSimpleDoc */ public static XmlDoc doc(String... fieldsAndValues) { XmlDoc d = new XmlDoc(); d.xml = TestHarness.makeSimpleDoc(fieldsAndValues); return d; }