当前位置: 首页>>代码示例>>Java>>正文


Java Requests.indexRequest方法代码示例

本文整理汇总了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);
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:57,代码来源:JLineRhinoCompleterTest.java

示例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);
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:50,代码来源:JLineRhinoCompleterTest.java


注:本文中的org.elasticsearch.client.Requests.indexRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。