Merge branch 'master' into feature/client_aggs_parsing

This commit is contained in:
javanna 2017-04-07 15:43:32 +02:00 committed by Luca Cavanna
commit 39e791291e
7 changed files with 34 additions and 21 deletions

View File

@ -44,6 +44,7 @@ import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.index.mapper.AllFieldMapper;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperService;
@ -569,7 +570,11 @@ public class MapperQueryParser extends AnalyzingQueryParser {
@Override
protected Query getWildcardQuery(String field, String termStr) throws ParseException {
if (termStr.equals("*") && field != null) {
if ("*".equals(field)) {
/**
* We rewrite _all:* to a match all query.
* TODO: We can remove this special case when _all is completely removed.
*/
if ("*".equals(field) || AllFieldMapper.NAME.equals(field)) {
return newMatchAllDocsQuery();
}
String actualField = field;

View File

@ -249,8 +249,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
String[] newNodes = internalCluster().startNodes(2, settings).stream().toArray(String[]::new);
ensureGreen();
clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForNodes("4").execute().actionGet();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
internalCluster().validateClusterFormed();
state = client().admin().cluster().prepareState().execute().actionGet().getState();
assertThat(state.nodes().getSize(), equalTo(4));

View File

@ -56,11 +56,13 @@ import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
@ -131,10 +133,10 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
client().admin().cluster().prepareHealth().setWaitForNodes("3").get();
ClusterService clusterService = internalCluster().getInstance(ClusterService.class, master);
final ArrayList<ClusterState> statesFound = new ArrayList<>();
final AtomicInteger numUpdates = new AtomicInteger();
final CountDownLatch nodesStopped = new CountDownLatch(1);
clusterService.addStateApplier(event -> {
statesFound.add(event.state());
numUpdates.incrementAndGet();
try {
// block until both nodes have stopped to accumulate node failures
nodesStopped.await();
@ -148,7 +150,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
nodesStopped.countDown();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).get(); // wait for all to be processed
assertThat(statesFound, Matchers.hasSize(2));
assertThat(numUpdates.get(), either(equalTo(1)).or(equalTo(2))); // due to batching, both nodes can be handled in same CS update
}
public void testNodeRejectsClusterStateWithWrongMasterNode() throws Exception {

View File

@ -822,7 +822,7 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
queryBuilder = new QueryStringQueryBuilder("_all:*");
query = queryBuilder.toQuery(context);
expected = new ConstantScoreQuery(new TermQuery(new Term("_field_names", "_all")));
expected = new MatchAllDocsQuery();
assertThat(query, equalTo(expected));
queryBuilder = new QueryStringQueryBuilder("*:*");

View File

@ -160,7 +160,9 @@ public class TopHitsTests extends BaseAggregationTestCase<TopHitsAggregationBuil
}
}
if (randomBoolean()) {
factory.highlighter(HighlightBuilderTests.randomHighlighterBuilder());
// parent test shuffles xContent, we need to make sure highlight fields are ordered
factory.highlighter(
HighlightBuilderTests.randomHighlighterBuilder().useExplicitFieldOrder(true));
}
return factory;
}

View File

@ -33,6 +33,7 @@ import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.HashSet;
import java.util.List;
@ -188,19 +189,23 @@ public class SpawnerNoBootstrapTests extends LuceneTestCase {
equalTo("plugin [test_plugin] does not have permission to fork native controller"));
}
private void createControllerProgram(Path outputFile) throws IOException {
Path outputDir = outputFile.getParent();
private void createControllerProgram(final Path outputFile) throws IOException {
final Path outputDir = outputFile.getParent();
Files.createDirectories(outputDir);
Files.write(outputFile, CONTROLLER_SOURCE.getBytes(StandardCharsets.UTF_8));
Set<PosixFilePermission> perms = new HashSet<>();
perms.add(PosixFilePermission.OWNER_READ);
perms.add(PosixFilePermission.OWNER_WRITE);
perms.add(PosixFilePermission.OWNER_EXECUTE);
perms.add(PosixFilePermission.GROUP_READ);
perms.add(PosixFilePermission.GROUP_EXECUTE);
perms.add(PosixFilePermission.OTHERS_READ);
perms.add(PosixFilePermission.OTHERS_EXECUTE);
Files.setPosixFilePermissions(outputFile, perms);
final PosixFileAttributeView view =
Files.getFileAttributeView(outputFile, PosixFileAttributeView.class);
if (view != null) {
final Set<PosixFilePermission> perms = new HashSet<>();
perms.add(PosixFilePermission.OWNER_READ);
perms.add(PosixFilePermission.OWNER_WRITE);
perms.add(PosixFilePermission.OWNER_EXECUTE);
perms.add(PosixFilePermission.GROUP_READ);
perms.add(PosixFilePermission.GROUP_EXECUTE);
perms.add(PosixFilePermission.OTHERS_READ);
perms.add(PosixFilePermission.OTHERS_EXECUTE);
Files.setPosixFilePermissions(outputFile, perms);
}
}
}

View File

@ -1059,13 +1059,13 @@ public final class InternalTestCluster extends TestCluster {
}
/** ensure a cluster is formed with all published nodes. */
private void validateClusterFormed() {
public synchronized void validateClusterFormed() {
String name = randomFrom(random, getNodeNames());
validateClusterFormed(name);
}
/** ensure a cluster is formed with all published nodes, but do so by using the client of the specified node */
private void validateClusterFormed(String viaNode) {
public synchronized void validateClusterFormed(String viaNode) {
Set<DiscoveryNode> expectedNodes = new HashSet<>();
for (NodeAndClient nodeAndClient : nodes.values()) {
expectedNodes.add(getInstanceFromNode(ClusterService.class, nodeAndClient.node()).localNode());