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