[TESTS] Added percolator rest tests.
This commit is contained in:
parent
9bc3d996ff
commit
efebb8d515
|
@ -0,0 +1,41 @@
|
||||||
|
---
|
||||||
|
"Basic multi-percolate":
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: percolator_index
|
||||||
|
type: my_type
|
||||||
|
id: 1
|
||||||
|
body: {foo: bar}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: percolator_index
|
||||||
|
type: .percolator
|
||||||
|
id: test_percolator
|
||||||
|
body:
|
||||||
|
query:
|
||||||
|
match_all: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
mpercolate:
|
||||||
|
body:
|
||||||
|
- percolate:
|
||||||
|
index: percolator_index
|
||||||
|
type: my_type
|
||||||
|
- doc:
|
||||||
|
foo: bar
|
||||||
|
- percolate:
|
||||||
|
index: percolator_index1
|
||||||
|
type: my_type
|
||||||
|
- doc:
|
||||||
|
foo: bar
|
||||||
|
- percolate:
|
||||||
|
index: percolator_index
|
||||||
|
type: my_type
|
||||||
|
id: 1
|
||||||
|
- doc:
|
||||||
|
foo: bar
|
||||||
|
|
||||||
|
- match: { responses.0.total: 1 }
|
||||||
|
- match: { responses.1.error: "IndexMissingException[[percolator_index1] missing]" }
|
||||||
|
- match: { responses.2.total: 1 }
|
|
@ -25,4 +25,16 @@
|
||||||
doc:
|
doc:
|
||||||
foo: bar
|
foo: bar
|
||||||
|
|
||||||
|
- match: {'total': 1}
|
||||||
- match: {'matches': [{_index: test_index, _id: test_percolator}]}
|
- match: {'matches': [{_index: test_index, _id: test_percolator}]}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
count_percolate:
|
||||||
|
index: test_index
|
||||||
|
type: test_type
|
||||||
|
body:
|
||||||
|
doc:
|
||||||
|
foo: bar
|
||||||
|
|
||||||
|
- is_false: matches
|
||||||
|
- match: {'total': 1}
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
---
|
||||||
|
"Percolate existing documents":
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.create:
|
||||||
|
index: percolator_index
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: percolator_index
|
||||||
|
type: .percolator
|
||||||
|
id: test_percolator
|
||||||
|
body:
|
||||||
|
query:
|
||||||
|
match_all: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: percolator_index
|
||||||
|
type: test_type
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
foo: bar
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.create:
|
||||||
|
index: my_index
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: my_index
|
||||||
|
type: my_type
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
foo: bar
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.refresh: {}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
percolate:
|
||||||
|
index: percolator_index
|
||||||
|
type: test_type
|
||||||
|
id: 1
|
||||||
|
|
||||||
|
- match: {'matches': [{_index: percolator_index, _id: test_percolator}]}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
percolate:
|
||||||
|
index: my_index
|
||||||
|
type: my_type
|
||||||
|
id: 1
|
||||||
|
percolate_index: percolator_index
|
||||||
|
percolate_type: test_type
|
||||||
|
|
||||||
|
- match: {'matches': [{_index: percolator_index, _id: test_percolator}]}
|
||||||
|
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: my_index
|
||||||
|
type: my_type
|
||||||
|
id: 1
|
||||||
|
body:
|
||||||
|
foo: bar
|
||||||
|
|
||||||
|
- do:
|
||||||
|
percolate:
|
||||||
|
index: my_index
|
||||||
|
type: my_type
|
||||||
|
id: 1
|
||||||
|
version: 2
|
||||||
|
percolate_index: percolator_index
|
||||||
|
percolate_type: test_type
|
||||||
|
|
||||||
|
- match: {'matches': [{_index: percolator_index, _id: test_percolator}]}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
catch: conflict
|
||||||
|
percolate:
|
||||||
|
index: my_index
|
||||||
|
type: my_type
|
||||||
|
id: 1
|
||||||
|
version: 1
|
||||||
|
percolate_index: percolator_index
|
||||||
|
percolate_type: test_type
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||||
import org.elasticsearch.index.engine.DocumentMissingException;
|
import org.elasticsearch.index.engine.DocumentMissingException;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
|
import org.elasticsearch.indices.IndexMissingException;
|
||||||
import org.elasticsearch.percolator.PercolatorService;
|
import org.elasticsearch.percolator.PercolatorService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.BaseTransportRequestHandler;
|
import org.elasticsearch.transport.BaseTransportRequestHandler;
|
||||||
|
@ -163,7 +164,15 @@ public class TransportMultiPercolateAction extends TransportAction<MultiPercolat
|
||||||
assert element != null;
|
assert element != null;
|
||||||
if (element instanceof PercolateRequest) {
|
if (element instanceof PercolateRequest) {
|
||||||
PercolateRequest percolateRequest = (PercolateRequest) element;
|
PercolateRequest percolateRequest = (PercolateRequest) element;
|
||||||
String[] concreteIndices = clusterState.metaData().concreteIndices(percolateRequest.indices(), percolateRequest.indicesOptions());
|
String[] concreteIndices;
|
||||||
|
try {
|
||||||
|
concreteIndices = clusterState.metaData().concreteIndices(percolateRequest.indices(), percolateRequest.indicesOptions());
|
||||||
|
} catch (IndexMissingException e) {
|
||||||
|
reducedResponses.set(slot, e);
|
||||||
|
responsesByItemAndShard.set(slot, new AtomicReferenceArray(0));
|
||||||
|
expectedOperationsPerItem.set(slot, new AtomicInteger(0));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Map<String, Set<String>> routing = clusterState.metaData().resolveSearchRouting(percolateRequest.routing(), percolateRequest.indices());
|
Map<String, Set<String>> routing = clusterState.metaData().resolveSearchRouting(percolateRequest.routing(), percolateRequest.indices());
|
||||||
// TODO: I only need shardIds, ShardIterator(ShardRouting) is only needed in TransportShardMultiPercolateAction
|
// TODO: I only need shardIds, ShardIterator(ShardRouting) is only needed in TransportShardMultiPercolateAction
|
||||||
GroupShardsIterator shards = clusterService.operationRouting().searchShards(
|
GroupShardsIterator shards = clusterService.operationRouting().searchShards(
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest {
|
||||||
verify(typesExists("test1", "test2"), true);
|
verify(typesExists("test1", "test2"), true);
|
||||||
verify(deleteByQuery("test1", "test2"), true);
|
verify(deleteByQuery("test1", "test2"), true);
|
||||||
verify(percolate("test1", "test2"), true);
|
verify(percolate("test1", "test2"), true);
|
||||||
verify(mpercolate(null, "test1", "test2"), true);
|
verify(mpercolate(null, "test1", "test2"), false);
|
||||||
verify(suggest("test1", "test2"), true);
|
verify(suggest("test1", "test2"), true);
|
||||||
verify(getAliases("test1", "test2"), true);
|
verify(getAliases("test1", "test2"), true);
|
||||||
verify(getFieldMapping("test1", "test2"), true);
|
verify(getFieldMapping("test1", "test2"), true);
|
||||||
|
@ -117,7 +117,7 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest {
|
||||||
verify(typesExists("test1", "test2").setIndicesOptions(options), true);
|
verify(typesExists("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(deleteByQuery("test1", "test2").setIndicesOptions(options), true);
|
verify(deleteByQuery("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(percolate("test1", "test2").setIndicesOptions(options), true);
|
verify(percolate("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(mpercolate(options, "test1", "test2").setIndicesOptions(options), true);
|
verify(mpercolate(options, "test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(suggest("test1", "test2").setIndicesOptions(options), true);
|
verify(suggest("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(getAliases("test1", "test2").setIndicesOptions(options), true);
|
verify(getAliases("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(getFieldMapping("test1", "test2").setIndicesOptions(options), true);
|
verify(getFieldMapping("test1", "test2").setIndicesOptions(options), true);
|
||||||
|
|
Loading…
Reference in New Issue