當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。