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


Java DocumentResult类代码示例

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


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


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