use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class RemoteRequestBuildersTests method testIntialSearchPath.
public void testIntialSearchPath() {
SearchRequest searchRequest = new SearchRequest().source(new SearchSourceBuilder());
assertEquals("/_search", initialSearchPath(searchRequest));
searchRequest.indices("a");
searchRequest.types("b");
assertEquals("/a/b/_search", initialSearchPath(searchRequest));
searchRequest.indices("a", "b");
searchRequest.types("c", "d");
assertEquals("/a,b/c,d/_search", initialSearchPath(searchRequest));
searchRequest.indices("cat,");
expectBadStartRequest(searchRequest, "Index", ",", "cat,");
searchRequest.indices("cat,", "dog");
expectBadStartRequest(searchRequest, "Index", ",", "cat,");
searchRequest.indices("dog", "cat,");
expectBadStartRequest(searchRequest, "Index", ",", "cat,");
searchRequest.indices("cat/");
expectBadStartRequest(searchRequest, "Index", "/", "cat/");
searchRequest.indices("cat/", "dog");
expectBadStartRequest(searchRequest, "Index", "/", "cat/");
searchRequest.indices("dog", "cat/");
expectBadStartRequest(searchRequest, "Index", "/", "cat/");
searchRequest.indices("ok");
searchRequest.types("cat,");
expectBadStartRequest(searchRequest, "Type", ",", "cat,");
searchRequest.types("cat,", "dog");
expectBadStartRequest(searchRequest, "Type", ",", "cat,");
searchRequest.types("dog", "cat,");
expectBadStartRequest(searchRequest, "Type", ",", "cat,");
searchRequest.types("cat/");
expectBadStartRequest(searchRequest, "Type", "/", "cat/");
searchRequest.types("cat/", "dog");
expectBadStartRequest(searchRequest, "Type", "/", "cat/");
searchRequest.types("dog", "cat/");
expectBadStartRequest(searchRequest, "Type", "/", "cat/");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class RestReindexActionTests method testReindexFromRemoteRequestParsing.
public void testReindexFromRemoteRequestParsing() throws IOException {
BytesReference request;
try (XContentBuilder b = JsonXContent.contentBuilder()) {
b.startObject();
{
b.startObject("source");
{
b.startObject("remote");
{
b.field("host", "http://localhost:9200");
}
b.endObject();
b.field("index", "source");
}
b.endObject();
b.startObject("dest");
{
b.field("index", "dest");
}
b.endObject();
}
b.endObject();
request = b.bytes();
}
try (XContentParser p = createParser(JsonXContent.jsonXContent, request)) {
ReindexRequest r = new ReindexRequest(new SearchRequest(), new IndexRequest());
RestReindexAction.PARSER.parse(p, r, null);
assertEquals("localhost", r.getRemoteInfo().getHost());
assertArrayEquals(new String[] { "source" }, r.getSearchRequest().indices());
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class ReindexRequestTests method newRequest.
@Override
protected ReindexRequest newRequest() {
ReindexRequest reindex = new ReindexRequest(new SearchRequest(), new IndexRequest());
reindex.getSearchRequest().indices("source");
reindex.getDestination().index("dest");
return reindex;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class SearchRequestTests method testIllegalArguments.
public void testIllegalArguments() {
SearchRequest searchRequest = new SearchRequest();
assertNotNull(searchRequest.indices());
assertNotNull(searchRequest.indicesOptions());
assertNotNull(searchRequest.types());
assertNotNull(searchRequest.searchType());
NullPointerException e = expectThrows(NullPointerException.class, () -> searchRequest.indices((String[]) null));
assertEquals("indices must not be null", e.getMessage());
e = expectThrows(NullPointerException.class, () -> searchRequest.indices((String) null));
assertEquals("index must not be null", e.getMessage());
e = expectThrows(NullPointerException.class, () -> searchRequest.indicesOptions(null));
assertEquals("indicesOptions must not be null", e.getMessage());
e = expectThrows(NullPointerException.class, () -> searchRequest.types((String[]) null));
assertEquals("types must not be null", e.getMessage());
e = expectThrows(NullPointerException.class, () -> searchRequest.types((String) null));
assertEquals("type must not be null", e.getMessage());
e = expectThrows(NullPointerException.class, () -> searchRequest.searchType((SearchType) null));
assertEquals("searchType must not be null", e.getMessage());
e = expectThrows(NullPointerException.class, () -> searchRequest.source(null));
assertEquals("source must not be null", e.getMessage());
e = expectThrows(NullPointerException.class, () -> searchRequest.scroll((TimeValue) null));
assertEquals("keepAlive must not be null", e.getMessage());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class SearchRequestTests method testSerialization.
public void testSerialization() throws Exception {
SearchRequest searchRequest = createSearchRequest();
try (BytesStreamOutput output = new BytesStreamOutput()) {
searchRequest.writeTo(output);
try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWriteableRegistry)) {
SearchRequest deserializedRequest = new SearchRequest();
deserializedRequest.readFrom(in);
assertEquals(deserializedRequest, searchRequest);
assertEquals(deserializedRequest.hashCode(), searchRequest.hashCode());
assertNotSame(deserializedRequest, searchRequest);
}
}
}
Aggregations