• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DocumentResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.searchbox.core.DocumentResult的典型用法代码示例。如果您正苦于以下问题:Java DocumentResult类的具体用法?Java DocumentResult怎么用?Java DocumentResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DocumentResult类属于io.searchbox.core包,在下文中一共展示了DocumentResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected Void doInBackground(User... search_parameters) {
    verifySettings();

    User user = search_parameters[0];
    String user_ID = user.getUser_Id();

    Index index = new Index.Builder(user).index("cmput301w17t8").type("user").id(user_ID).build();

    try {
        DocumentResult result = client.execute(index);
        if (!result.isSucceeded()) {
            Log.i("Error", "Elasticsearch was not able to update user.");
        }
    } catch (Exception e) {
        Log.i("Error", "The application failed to build and send user.");
    }

    return null;
}
 
开发者ID:CMPUT301W17T08,项目名称:Moodr,代码行数:21,代码来源:ElasticSearchUserController.java


示例2: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected String doInBackground(Mood... moods) {
    verifySettings();

    String moodId = null;

    for (Mood mood : moods) {
        Index index1 = new Index.Builder(mood).index("cmput301w17t8").type("mood").id(mood.getId()).build();

        try {
            DocumentResult result = client.execute(index1);
            if (!result.isSucceeded()) {
                Log.i("Error", "Elasticsearch was not able to add mood.");
            } else {
                moodId = result.getId();
            }
        } catch (Exception e) {
            Log.i("Error", "The application failed to build and send mood.");
        }
    }
    return moodId;
}
 
开发者ID:CMPUT301W17T08,项目名称:Moodr,代码行数:23,代码来源:ElasticSearchMoodController.java


示例3: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
        protected Void doInBackground(Attributes... attrs) {

            verifySettings();

            for (Attributes attr : attrs) {
                Index index = new Index.Builder(attr).index(db).type(attrType).id(Integer.toString(attr.getUid())).refresh(true).build();


                try {
                    // where is the client?
                    DocumentResult result = client.execute(index);
                    if (result.isSucceeded()) {
//                        Log.i("HabitUpDEBUG", "AddAttr SUCCESS");
                    }

                    else{
                        Log.i("Error", "Elasticsearch was not able to add the Attributes");
                    }
                } catch (Exception e) {
                    Log.i("Error", "The application failed to build and send the Attributes");
                }
            }

            return null;
        }
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:27,代码来源:ElasticSearchController.java


示例4: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected Profile doInBackground(Profile... profiles){
    verifySettings();

    Profile retProfile = null;
    for (Profile profile: profiles){
        Index index = new Index.Builder(profile).index(appESIndex).type("profile").build();

        try {
            DocumentResult result = client.execute(index);
            if (result.isSucceeded()){
                profile.setUserId(result.getId());
                retProfile = profile;
            }else{
                Log.i("Error","Elasticsearch was unable to add profile");
            }
        }
        catch (Exception e){
            e.printStackTrace();
            //Log.i("Error", "The app failed to build and send profile " + e.getCause());
        }
    }
    return retProfile;
}
 
开发者ID:CMPUT301F17T09,项目名称:GoalsAndHabits,代码行数:25,代码来源:ElasticSearchController.java


示例5: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
/**
 * Gets particular user/info
 * @param users
 * @return
 */
@Override
protected Void doInBackground(Account... users) {
    verifySettings();

    for (Account user : users) {
        Index index = new Index.Builder(user).index(INDEX).type(USER_TYPE).id(user.getUserName()).build();

        try {
            // where is the client?
            DocumentResult result = client.execute(index);
            if (result.isSucceeded()) {
                result.getId();
            } else {
                Log.i("Error", "Elasticsearch was not able to add the user");
            }
        } catch (Exception e) {
            Log.i("Error", "The application failed to build and send the user info.");
        }

    }
    return null;
}
 
开发者ID:CMPUT301F17T17,项目名称:Habitizer,代码行数:28,代码来源:ElasticsearchController.java


示例6: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected String doInBackground(User... users) {
    verifySettings();

    // Enforce adding only one user with this async task
    if (users.length > 1)
        throw new RuntimeException("Illegal Task Call: One user at a time.");

    String assignedUserID = null;
    Index index = new Index.Builder(users[0]).index(INDEX_NAME).type("user").build();
    try {
        DocumentResult result = client.execute(index);
        if (result.isSucceeded()){
            assignedUserID = result.getId().toString();
        } else {
            Log.i("Error", "Elastic search was not able to add the user.");
        }
    } catch (Exception e) {
        Log.i("Error", "The application failed to build and send the users.");
    }
    return assignedUserID;
}
 
开发者ID:CMPUT301F17T23,项目名称:routineKeen,代码行数:23,代码来源:ElasticSearchController.java


示例7: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected Void doInBackground(Request... requests) {
    verifySettings();

    for (Request request : requests) {
        Index index = new Index.Builder(request).index("cmput301f16t01").type("request").build();
        try {
            DocumentResult result = client.execute(index);
            if (result.isSucceeded()) {
                request.setId(result.getId());
            } else {
                Log.i("Add Request Failure", "Failed to add request to elastic search");
            }
        } catch (IOException e) {
            Log.i("Add Request Failure", "Something went wrong adding a request to elastic search.");
            e.printStackTrace();
        }
    }
    return null;
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:21,代码来源:ElasticRequestController.java


示例8: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
/**
 * Async task to add user to elastic search.
 *
 * @param users these are the users that we will add in elastic search
 */
@Override
protected Void doInBackground(User... users) {
    verifySettings();

    for (User user : users) {
        Index index = new Index.Builder(user).index("cmput301f16t01").type("user").build();

        try {
            DocumentResult result = client.execute(index);

            if (result.isSucceeded()) {
                user.setId(result.getId());
            } else {
                Log.i("Add User Unsuccessful", "Failed to add user to elastic search?");
            }
        } catch (IOException e) {
            Log.i("Add User Failure", "Something went wrong adding a user to elastic search.");
            e.printStackTrace();
        }
    }

    return null;
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:29,代码来源:ElasticUserController.java


示例9: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected Void doInBackground(Account... newAccount) {
    verifySettings();

    Index index = new Index.Builder(newAccount[0]).index("f16t14").type("Account").build();

    try {
        DocumentResult result = client.execute(index);
        if (result.isSucceeded()) {
            newAccount[0].setId(result.getId());
        }
        else {
            Log.i("Error", "Elastic search was not able to add the account.");
        }
    }
    catch (Exception e) {
        Log.i("Error", "We failed to add an account to elastic search!");
        e.printStackTrace();
    }

    return null;
}
 
开发者ID:CMPUT301F16T14,项目名称:Project,代码行数:23,代码来源:ElasticsearchAccountController.java


示例10: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected Void doInBackground(Request... newRequest) {
    verifySettings();

    Index index = new Index.Builder(newRequest[0]).index("f16t14").type("Request").build();

    try {
        DocumentResult result = client.execute(index);
        if (result.isSucceeded()) {
            newRequest[0].setId(result.getId());
        }
        else {
            Log.i("Error", "Elastic search was not able to add the request.");
        }
    }
    catch (Exception e) {
        Log.i("Error", "We failed to add the request to elastic search!");
        e.printStackTrace();
    }

    return null;
}
 
开发者ID:CMPUT301F16T14,项目名称:Project,代码行数:23,代码来源:ElasticsearchRequestController.java


示例11: saveIndex

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
public IEsItem saveIndex(IEsItem doc) throws Exception {
	Index.Builder builder = new Index.Builder(doc);
	if (doc.getIndex() != null) {
		builder.index(doc.getIndex());
	}
	if (doc.getType() != null) {
		builder.type(doc.getType());
	}
	if (doc.getId() != null) {
		builder.id(doc.getId());
	}

	DocumentResult result = _exec(builder.build());
	if (result != null) {
		doc.setIndex(result.getIndex());
		doc.setType(result.getType());
		doc.setId(result.getId());
		return doc;
	}
	return null;
}
 
开发者ID:DataSays,项目名称:wES,代码行数:23,代码来源:JestClient.java


示例12: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected Boolean doInBackground(User... search_parameters) {
    verifySettings();

    boolean addable = false;
    Index index = new Index.Builder(search_parameters[0]).index(INDEX).type(USER).id(search_parameters[0].getId()).build();

    try {
        DocumentResult result = client.execute(index);
        if (result.isSucceeded()) {
            addable = true;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return addable;
}
 
开发者ID:CMPUT301F16T02,项目名称:Dryver,代码行数:18,代码来源:ElasticSearchController.java


示例13: createRequest

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
/**
 * A generic function creates or updates a document in an elastic search database based on a type
 * and ID
 * @param type
 * @param ID
 * @param jsonValue
 * @throws IOException
 * @return result
 * @nullable
 */
@Nullable
private JestResult createRequest(String type, String ID, String jsonValue) throws IOException {
    // Takes strings of the type of object, [user, ride, request], the id of the object to create
    // and the json version of that object and posts it to the server
    // It returns a jsonObject representing the results of the operation or null if it failed
    System.out.println(jsonValue);
    Index index = new Index.Builder(jsonValue).index(databaseName).type(type).id(ID).build();
    DocumentResult result = client.execute(index);
    if (result.isSucceeded()) {
        return result;
    }
    else {
        Log.d("error", result.getJsonObject().toString());
        Log.i("Error", "The search query failed to find the Class that matched.");
        return null;
    }
}
 
开发者ID:CMPUT301F16T04,项目名称:Ridr,代码行数:28,代码来源:AsyncDatabaseController.java


示例14: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected String doInBackground(Book... books) {
    verifyClient();

    for (Book book : books) {
        Index index = new Index.Builder(book).index(teamdir).type(booktype).build();
        try {
            DocumentResult result = client.execute(index);
            if (result.isSucceeded()) {
                // Set ID
                return result.getId();
            } else {
                Log.i("TODO", "doInBackground: Add book did not succeed");
            }
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }

    }

    return null;
}
 
开发者ID:CMPUT301W16T12,项目名称:ProjectFive,代码行数:24,代码来源:ESController.java


示例15: store

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
/**
 * Store an entity
 * 
 * @param entity
 *            entity to store
 * @param create
 *            if true, the entity will only be created freshly, never
 *            updated
 * @return true if the operation was successful. Only false if create is
 *         true and the document already exists
 * @throws RuntimeException
 *             if the store operation fails
 */
public boolean store(EsEntity<?> entity, boolean create) {
    Builder builder;
    {
        builder = new Index.Builder(entity).index(EsNameHelper.index(entity.getClass()))
                .type(EsNameHelper.type(entity.getClass())).id(entity.getId());
    }
    if (create)
        builder.setParameter("op_type", "create");
    if (entity.getVersion() != null)
        builder.setParameter("version", entity.getVersion().toString());

    DocumentResult result = execute(builder.build());

    if (result.isSucceeded()) {
        if (Strings.isNullOrEmpty(entity.getId()))
            entity.setId(result.getId());
        entity.setVersion(result.getJsonObject().get("_version").getAsLong());
    }
    if (create)
        return result.isSucceeded();
    assertSuccessful(result);
    return true;
}
 
开发者ID:ruediste,项目名称:rise,代码行数:37,代码来源:EsHelper.java


示例16: testConvertToJestActionIndex

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Test
public void testConvertToJestActionIndex() throws Exception {
  HTTPBulkLoader loader = getBulkLoader();
  ActionRequestKey key = ActionRequestKey.newBuilder()
      .setAction(Action.INDEX)
      .setId("myId")
      .build();
  BulkableAction<DocumentResult> action = loader.convertToJestAction(new HTTPBulkLoader.ActionRequest(key, "fakeindex", "faketype", 100L, "{}"));
  assertEquals("index", action.getBulkMethodName());
  assertEquals("myId", action.getId());
  assertEquals("fakeindex", action.getIndex());
  assertEquals("faketype", action.getType());
  assertEquals("{}", action.getData(new Gson()));
  assertEquals(0, action.getParameter(Parameters.VERSION).size());
  assertEquals(0, action.getParameter(Parameters.VERSION_TYPE).size());

  ActionRequestKey keyWithVersion = ActionRequestKey.newBuilder()
      .setAction(Action.INDEX)
      .setId("myId")
      .setVersion(123L)
      .setVersionType(VersionType.EXTERNAL)
      .build();
  BulkableAction<DocumentResult> actionWithVersion = loader.convertToJestAction(new HTTPBulkLoader.ActionRequest(keyWithVersion, "fakeindex", "faketype", 100L, "{}"));
  assertEquals("external", actionWithVersion.getParameter(Parameters.VERSION_TYPE).toArray()[0]);
  assertEquals(123L, actionWithVersion.getParameter(Parameters.VERSION).toArray()[0]);
}
 
开发者ID:quantiply,项目名称:rico,代码行数:27,代码来源:HTTPBulkLoaderTest.java


示例17: testConvertToJestActionUpdate

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Test
public void testConvertToJestActionUpdate() throws Exception {
  HTTPBulkLoader loader = getBulkLoader();
  ActionRequestKey key = ActionRequestKey.newBuilder()
      .setAction(Action.UPDATE)
      .setId("myId")
      .setVersion(123L)
      .setVersionType(VersionType.EXTERNAL)
      .build();
  BulkableAction<DocumentResult> action = loader.convertToJestAction(new HTTPBulkLoader.ActionRequest(key, "fakeindex", "faketype", 100L, "{}"));
  assertEquals("update", action.getBulkMethodName());
  assertEquals("myId", action.getId());
  assertEquals("fakeindex", action.getIndex());
  assertEquals("faketype", action.getType());
  assertEquals("external", action.getParameter(Parameters.VERSION_TYPE).toArray()[0]);
  assertEquals(123L, action.getParameter(Parameters.VERSION).toArray()[0]);
  assertEquals("{}", action.getData(new Gson()));
}
 
开发者ID:quantiply,项目名称:rico,代码行数:19,代码来源:HTTPBulkLoaderTest.java


示例18: testConvertToJestActionDelete

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Test
public void testConvertToJestActionDelete() throws Exception {
  HTTPBulkLoader loader = getBulkLoader();
  ActionRequestKey key = ActionRequestKey.newBuilder()
      .setAction(Action.DELETE)
      .setId("myId")
      .setVersion(123L)
      .setVersionType(VersionType.EXTERNAL)
      .build();
  BulkableAction<DocumentResult> action = loader.convertToJestAction(new HTTPBulkLoader.ActionRequest(key, "fakeindex", "faketype", 100L, null));
  assertEquals("delete", action.getBulkMethodName());
  assertEquals("myId", action.getId());
  assertEquals("fakeindex", action.getIndex());
  assertEquals("faketype", action.getType());
  assertEquals("external", action.getParameter(Parameters.VERSION_TYPE).toArray()[0]);
  assertEquals(123L, action.getParameter(Parameters.VERSION).toArray()[0]);
  assertEquals(null, action.getData(new Gson()));
}
 
开发者ID:quantiply,项目名称:rico,代码行数:19,代码来源:HTTPBulkLoaderTest.java


示例19: intropectorCanAccessActionPayload

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Test
public void intropectorCanAccessActionPayload() {

    // given
    BatchItemIntrospector<AbstractDocumentTargetedAction<DocumentResult>> introspector = new JestActionIntrospector();
    String testPayload = "testPayload";
    AbstractDocumentTargetedAction<DocumentResult> action = new Index.Builder(testPayload).build();

    // when
    String payload = introspector.getPayload(action);

    // then
    Assert.assertEquals(testPayload, payload);
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:15,代码来源:JestActionIntrospectorTest.java


示例20: doInBackground

import io.searchbox.core.DocumentResult; //导入依赖的package包/类
@Override
protected Void doInBackground(WarItem... items) {

    if(isOnline()==false){
        for(int i = 0; i < items.length; i++) {
            WarItem waritem = items[i];
            itemsList.add(waritem);
        }
        //adapterItems.notifyDataSetChanged();
        saveInFileItems(additem);
        return null;

    }
    verifyClient();

    // Since AsyncTasks work on arrays, we need to work with arrays as well (>= 1 tweet)
    for(int i = 0; i < items.length; i++) {
        WarItem item = items[i];

        Index index = new Index.Builder(item).index("warondemand").type("items").build();
        try {
            DocumentResult result = client.execute(index);
            if(result.isSucceeded()) {
                // Set the ID to tweet that elasticsearch told me it was
                item.setId(result.getId());
            } else {
                // TODO: Add an error message, because this was puzzling.
                // TODO: Right here it will trigger if the insert fails
                Log.i("TODO", "We actually failed here, adding a user");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    Log.i("Success", "We have added an item to the DB");
    return null;
}
 
开发者ID:Hegberg,项目名称:Agile_Android_Abstracts,代码行数:38,代码来源:DatabaseController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SweetAlertDialog类代码示例发布时间:2022-05-21
下一篇:
Java OWLClassExpression类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap