This commit is contained in:
Karl Wright 2017-11-21 18:05:29 -05:00
commit d44b5ee3ab
12 changed files with 59 additions and 34 deletions

View File

@ -112,6 +112,13 @@ Tests
* LUCENE-8035: Run tests with JDK-specific options: --illegal-access=deny
on Java 9+. (Uwe Schindler)
======================= Lucene 7.1.1 =======================
Bug Fixes
* LUCENE-8055: MemoryIndex.MemoryDocValuesIterator returns 2 documents
instead of 1. (Simon Willnauer)
Build
* LUCENE-6144: Upgrade Ivy to 2.4.0; 'ant ivy-bootstrap' now removes old Ivy

View File

@ -929,7 +929,7 @@ public class MemoryIndex {
}
int docId() {
return doc > 1 ? NumericDocValues.NO_MORE_DOCS : doc;
return doc > 0 ? NumericDocValues.NO_MORE_DOCS : doc;
}
}

View File

@ -59,6 +59,7 @@ import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.CollectionStatistics;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.PhraseQuery;
@ -274,6 +275,7 @@ public class TestMemoryIndex extends LuceneTestCase {
NumericDocValues numericDocValues = leafReader.getNumericDocValues("numeric");
assertEquals(0, numericDocValues.nextDoc());
assertEquals(29L, numericDocValues.longValue());
assertEquals(DocIdSetIterator.NO_MORE_DOCS, numericDocValues.nextDoc());
SortedNumericDocValues sortedNumericDocValues = leafReader.getSortedNumericDocValues("sorted_numeric");
assertEquals(0, sortedNumericDocValues.nextDoc());
assertEquals(5, sortedNumericDocValues.docValueCount());
@ -282,14 +284,17 @@ public class TestMemoryIndex extends LuceneTestCase {
assertEquals(32L, sortedNumericDocValues.nextValue());
assertEquals(32L, sortedNumericDocValues.nextValue());
assertEquals(33L, sortedNumericDocValues.nextValue());
assertEquals(DocIdSetIterator.NO_MORE_DOCS, sortedNumericDocValues.nextDoc());
BinaryDocValues binaryDocValues = leafReader.getBinaryDocValues("binary");
assertEquals(0, binaryDocValues.nextDoc());
assertEquals("a", binaryDocValues.binaryValue().utf8ToString());
assertEquals(DocIdSetIterator.NO_MORE_DOCS, binaryDocValues.nextDoc());
SortedDocValues sortedDocValues = leafReader.getSortedDocValues("sorted");
assertEquals(0, sortedDocValues.nextDoc());
assertEquals("b", sortedDocValues.binaryValue().utf8ToString());
assertEquals(0, sortedDocValues.ordValue());
assertEquals("b", sortedDocValues.lookupOrd(0).utf8ToString());
assertEquals(DocIdSetIterator.NO_MORE_DOCS, sortedDocValues.nextDoc());
SortedSetDocValues sortedSetDocValues = leafReader.getSortedSetDocValues("sorted_set");
assertEquals(3, sortedSetDocValues.getValueCount());
assertEquals(0, sortedSetDocValues.nextDoc());
@ -300,6 +305,7 @@ public class TestMemoryIndex extends LuceneTestCase {
assertEquals("c", sortedSetDocValues.lookupOrd(0L).utf8ToString());
assertEquals("d", sortedSetDocValues.lookupOrd(1L).utf8ToString());
assertEquals("f", sortedSetDocValues.lookupOrd(2L).utf8ToString());
assertEquals(DocIdSetIterator.NO_MORE_DOCS, sortedDocValues.nextDoc());
}
public void testDocValues_resetIterator() throws Exception {

View File

@ -19,17 +19,12 @@ package org.apache.solr.core;
import com.google.common.collect.Lists;
import org.apache.http.annotation.Experimental;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.logging.MDCLoggingContext;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.util.DefaultSolrThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collection;
@ -539,21 +534,22 @@ class SolrCores implements Observer {
return false;
}
// Let transient cache implementation tell us when it ages out a corel
// Let transient cache implementation tell us when it ages out a core
@Override
public void update(Observable o, Object arg) {
synchronized (modifyLock) {
SolrCore core = (SolrCore) arg;
SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
cmd.openSearcher = false;
cmd.waitSearcher = false;
try {
core.getUpdateHandler().commit(cmd);
} catch (IOException e) {
log.warn("Caught exception trying to close a transient core, ignoring as it should be benign");
}
pendingCloses.add(core); // Essentially just queue this core up for closing.
// Erick Erickson debugging TestLazyCores. With this un-commented, we get no testLazyCores failures.
// SolrCore core = (SolrCore) arg;
// SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
// CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
// cmd.openSearcher = false;
// cmd.waitSearcher = false;
// try {
// core.getUpdateHandler().commit(cmd);
// } catch (IOException e) {
// log.warn("Caught exception trying to close a transient core, ignoring as it should be benign");
// }
pendingCloses.add((SolrCore) arg); // Essentially just queue this core up for closing.
modifyLock.notifyAll(); // Wakes up closer thread too
}
}

View File

@ -813,7 +813,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
@Override
public void close() throws IOException {
log.debug("closing " + this);
commitTracker.close();
softCommitTracker.close();

View File

@ -43,4 +43,7 @@ A solrconfig.xml snippet containing indexConfig settings for randomized testing.
to vary the lockType canset it as needed.
-->
<lockType>${solr.tests.lockType:single}</lockType>
<infoStream>${solr.tests.infostream:false}</infoStream>
</indexConfig>

View File

@ -786,6 +786,9 @@ public class TestLazyCores extends SolrTestCaseJ4 {
// Cores 2, 3, 6, 7, 8, 9 are transient
@Test
public void testNoCommit() throws Exception {
String infoStream = System.getProperty("solr.tests.infostream");
System.setProperty("solr.tests.infostream","true");
CoreContainer cc = init();
String[] coreList = new String[]{
"collection2",
@ -832,6 +835,11 @@ public class TestLazyCores extends SolrTestCaseJ4 {
} finally {
cc.shutdown();
}
if (infoStream != null) {
System.setProperty("solr.tests.infostream", infoStream);
} else {
System.clearProperty("solr.tests.infostream");
}
}
private void add10(SolrCore core) throws IOException {

View File

@ -133,10 +133,6 @@
<delete dir="${build.content.dir}" />
<mkdir dir="${build.content.dir}" />
<echo>Copying all examples to build directory...</echo>
<copy todir="${build.content.dir}">
<fileset dir="../solrj/src/test/org/apache/solr/client/ref_guide_examples" />
</copy>
<echo>Copying all non template files from src ...</echo>
<copy todir="${build.content.dir}">
<fileset dir="src">
@ -210,6 +206,7 @@
<!-- NOTE: If you add any attributes here for use in adoc files, you almost certainly need to also add
them to the _config.yml.template file for building the jekyll site as well
-->
<attribute key="solr-root-path" value="../../../" />
<attribute key="solr-guide-draft-status" value="${solr-guide-draft-status}" />
<attribute key="solr-guide-version" value="${solr-guide-version}" />
<attribute key="solr-docs-version" value="${solr-docs-version}" />

View File

@ -69,6 +69,7 @@ asciidoc: {}
# NOTE: If you add any attributes here for use in adoc files, you almost certainly need to also add
# them to the <asciidoctor:convert/> ant task for building the PDF as well.
solr-attributes: &solr-attributes-ref
solr-root-path: "../../../"
solr-guide-draft-status: "${solr-guide-draft-status}"
solr-guide-version: "${solr-guide-version}"
solr-guide-version-path: "${solr-guide-version-path}"
@ -79,6 +80,7 @@ solr-attributes: &solr-attributes-ref
build-year: "${current.year}"
asciidoctor:
safe: 0
attributes:
<<: *solr-attributes-ref
icons: "font"

View File

@ -18,6 +18,10 @@
margin: 10px 0;
}
ul.nav.nav-pills li {
margin-left: 1px;
}
.pageSummary {
font-size:13px;
display:block;

View File

@ -1510,7 +1510,7 @@ table.tableblock #preamble > .sectionbody > .paragraph:first-of-type p
.exampleblock > .content
{
margin-bottom: 1.25em;
padding: 1.25em;
padding: 0 1em 1em 1em;
border-width: 1px;
border-style: solid;
border-color: #e6e6e6;

View File

@ -1,4 +1,6 @@
= Using SolrJ
:solr-root-path: ../../
:example-source-dir: {solr-root-path}solrj/src/test/org/apache/solr/client/ref_guide_examples/
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@ -95,8 +97,8 @@ Most SolrJ configuration happens at the `SolrClient` level. The most common/imp
==== Base URLs
Most `SolrClient` implementations (with the notable exception of `CloudSolrClient`) require users to specify one or more Solr base URLs, which the client then uses to send HTTP requests to Solr. The path users include on the base URL they provide has an effect on the behavior of the created client from that point on.
. A URL with a path pointing to a specific core or collection (e.g., `http://hostname:8983/solr/core1`). When a core or collection is specified in the base URL, subsequent requests made with that client are not required to re-specify the affected collection. However, the client is limited to sending requests to that core/collection, and can not send requests to any others.
. A URL pointing to the root Solr path (e.g., `http://hostname:8983/solr`). When no core or collection is specified in the base URL, requests can be made to any core/collection, but the affected core/collection must be specified on all requests.
. A URL with a path pointing to a specific core or collection (e.g., `\http://hostname:8983/solr/core1`). When a core or collection is specified in the base URL, subsequent requests made with that client are not required to re-specify the affected collection. However, the client is limited to sending requests to that core/collection, and can not send requests to any others.
. A URL pointing to the root Solr path (e.g., `\http://hostname:8983/solr`). When no core or collection is specified in the base URL, requests can be made to any core/collection, but the affected core/collection must be specified on all requests.
Generally speaking, if your `SolrClient` will only be used on a single core/collection, including that entity in the path is the most convenient. Where more flexibility is required, the collection/core should be excluded.
@ -105,7 +107,7 @@ All `SolrClient` implementations allow users to specify the connection and read
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-solrclient-timeouts]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-solrclient-timeouts]
----
When these values are not explicitly provided, SolrJ falls back to using the defaults for the OS/environment is running on.
@ -117,14 +119,14 @@ The following snippet uses a SolrClient to query Solr's "techproducts" example c
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-query-with-raw-solrparams]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-query-with-raw-solrparams]
----
`SolrParams` has a `SolrQuery` subclass, which provides some convenience methods that greatly simplifies query creation. The following snippet shows how the query from the previous example can be built using some of the convenience methods in `SolrQuery`:
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-query-with-solrquery]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-query-with-solrquery]
----
== Indexing in SolrJ
@ -135,7 +137,7 @@ The following example shows how to use SolrJ to add a document to Solr's "techpr
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-index-with-raw-solrinputdoc]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-index-with-raw-solrinputdoc]
----
CAUTION: The indexing examples above are intended to show syntax. For brevity, they break several Solr indexing best-practices. Under normal circumstances, documents should be indexed in larger batches, instead of one at a time. It is also suggested that Solr administrators commit documents using Solr's autocommit settings, and not using explicit `commit()` invocations.
@ -149,21 +151,21 @@ The example snippet below shows an annotated `TechProduct` class that can be use
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-techproduct-value-type]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-techproduct-value-type]
----
Application code with access to the annotated `TechProduct` class above can index `TechProduct` objects directly without any conversion, as in the example snippet below:
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-index-bean-value-type]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-index-bean-value-type]
----
Similarly, search results can be converted directly into bean objects using the `getBeans()` method on `QueryResponse`:
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-query-bean-value-type]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-query-bean-value-type]
----
== Other APIs
@ -173,5 +175,5 @@ The example below shows how SolrJ users can call the CLUSTERSTATUS API of SolrCl
[source,java,indent=0]
----
include::UsingSolrJRefGuideExamplesTest.java[tag=solrj-other-apis]
include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-other-apis]
----