本文整理匯總了Java中org.elasticsearch.client.Requests.indexRequest方法的典型用法代碼示例。如果您正苦於以下問題:Java Requests.indexRequest方法的具體用法?Java Requests.indexRequest怎麽用?Java Requests.indexRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.client.Requests
的用法示例。
在下文中一共展示了Requests.indexRequest方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCompleteNestedNativeJavaObject
import org.elasticsearch.client.Requests; //導入方法依賴的package包/類
@Test
public void testCompleteNestedNativeJavaObject() {
NativeJavaObject nativeJavaObject = new RhinoCustomNativeJavaObject(completer.getScope().get(), Requests.indexRequest("index_name"), IndexRequest.class);
nativeJavaObject.setPrototype(Context.getCurrentContext().newObject(completer.getScope().get()));
NativeJavaObject nestedDativeJavaObject = new RhinoCustomNativeJavaObject(completer.getScope().get(), Requests.indexRequest("index_name"), IndexRequest.class);
nestedDativeJavaObject.setPrototype(Context.getCurrentContext().newObject(completer.getScope().get()));
ScriptableObject.putProperty(nativeJavaObject, "typeNested", nestedDativeJavaObject);
completer.getScope().registerJavaObject("ir", nativeJavaObject);
List<CharSequence> candidates = new ArrayList<CharSequence>();
String input = "ir.ty";
int output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 2);
Assert.assertTrue(candidates.contains("type()"));
Assert.assertTrue(candidates.contains("typeNested"));
Assert.assertEquals(output, 3);
candidates.clear();
input = "ir.type('type_name').id";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 1);
Assert.assertEquals(candidates.get(0), "id()");
Assert.assertEquals(output, 21);
candidates.clear();
input = "ir.type('type_name').id(\"id\").so";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 2);
Assert.assertTrue(candidates.contains("source()"));
Assert.assertTrue(candidates.contains("sourceAsMap()"));
Assert.assertEquals(output, 30);
candidates.clear();
input = "ir.typeNested.ty";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 1);
Assert.assertEquals(candidates.get(0), "type()");
Assert.assertEquals(output, 14);
candidates.clear();
input = "ir.typeNested.type('type_name').id";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 1);
Assert.assertEquals(candidates.get(0), "id()");
Assert.assertEquals(output, 32);
candidates.clear();
input = "ir.typeNested.type('type_name').id(\"id\").so";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 2);
Assert.assertTrue(candidates.contains("source()"));
Assert.assertTrue(candidates.contains("sourceAsMap()"));
Assert.assertEquals(output, 41);
}
示例2: testCompleteNestedNativeJavaObjectNonJavaIdentifier
import org.elasticsearch.client.Requests; //導入方法依賴的package包/類
@Test
public void testCompleteNestedNativeJavaObjectNonJavaIdentifier() {
NativeJavaObject nativeJavaObject = new RhinoCustomNativeJavaObject(completer.getScope().get(), Requests.indexRequest("index_name"), IndexRequest.class);
nativeJavaObject.setPrototype(Context.getCurrentContext().newObject(completer.getScope().get()));
NativeJavaObject nestedDativeJavaObject = new RhinoCustomNativeJavaObject(completer.getScope().get(), Requests.indexRequest("index_name"), IndexRequest.class);
nestedDativeJavaObject.setPrototype(Context.getCurrentContext().newObject(completer.getScope().get()));
ScriptableObject.putProperty(nativeJavaObject, "type-name", nestedDativeJavaObject);
completer.getScope().registerJavaObject("ir", nativeJavaObject);
List<CharSequence> candidates = new ArrayList<CharSequence>();
String input = "ir.ty";
int output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 2);
Assert.assertTrue(candidates.contains("type()"));
Assert.assertTrue(candidates.contains("type-name"));
Assert.assertEquals(output, 3);
candidates.clear();
input = "ir.type('type_name').id";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 1);
Assert.assertEquals(candidates.get(0), "id()");
Assert.assertEquals(output, 21);
candidates.clear();
input = "ir.type('type_name').id(\"id\").so";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 2);
Assert.assertTrue(candidates.contains("source()"));
Assert.assertTrue(candidates.contains("sourceAsMap()"));
Assert.assertEquals(output, 30);
candidates.clear();
input = "ir['type-name'].ty";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 1);
Assert.assertEquals(candidates.get(0), "type()");
Assert.assertEquals(output, 16);
candidates.clear();
input = "ir['type-name'].type('type_name').id(\"id\").so";
output = completer.complete(input, input.length(), candidates);
Assert.assertEquals(candidates.size(), 2);
Assert.assertTrue(candidates.contains("source()"));
Assert.assertTrue(candidates.contains("sourceAsMap()"));
Assert.assertEquals(output, 43);
}