本文整理汇总了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);
}