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


Java SearchResult.isSucceeded方法代码示例

本文整理汇总了Java中io.searchbox.core.SearchResult.isSucceeded方法的典型用法代码示例。如果您正苦于以下问题:Java SearchResult.isSucceeded方法的具体用法?Java SearchResult.isSucceeded怎么用?Java SearchResult.isSucceeded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.searchbox.core.SearchResult的用法示例。


在下文中一共展示了SearchResult.isSucceeded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected Pair<SearchResult, Boolean> doInBackground(String... search_parameters) {
    verifySettings();

    String typeId = search_parameters[0];
    String finalQuery = getCompleteQuery(search_parameters[1]);
    Search search = new Search.Builder(finalQuery).addIndex(INDEX).addType(typeId).build();

    try {
        SearchResult result = client.execute(search);
        if (result.isSucceeded()) {
            return new Pair<>(result, Boolean.TRUE);
        } else {
            Log.i("Error", "the search query failed to find any objects that matched");
        }
    }
    catch (Exception e) {
        Log.i("Error", "Something went wrong when we tried to communicate with the elasticsearch server!");
        return new Pair<>(null, Boolean.FALSE);
    }

    return new Pair<>(null, Boolean.TRUE);
}
 
开发者ID:CMPUT301F17T15,项目名称:CIA,代码行数:24,代码来源:ElasticSearchUtilities.java

示例2: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected ArrayList<Profile> doInBackground(String... search_parameters){
    verifySettings();

    ArrayList<Profile> profiles = new ArrayList<Profile>();

    String query = "{\n"
            + "   \"query\" : {\n"
            + "        \"term\" : { \"username\" : \""+search_parameters[0]+"\"}\n"
            + "    }\n"
            + "}";
    Search search = new Search.Builder(query).addIndex(appESIndex).addType("profile").build();

    try{
        SearchResult result = client.execute(search);
        if (result.isSucceeded()){
            List<Profile> foundProfiles = result.getSourceAsObjectList(Profile.class);
            profiles.addAll(foundProfiles);
        }else{
            Log.i("Error","ElasticSearch search query failed");
        }
    }catch (Exception e){
        Log.i("Error","ElasticSearch filed to find profiles");
    }
    return profiles;
}
 
开发者ID:CMPUT301F17T09,项目名称:GoalsAndHabits,代码行数:27,代码来源:ElasticSearchController.java

示例3: getGamesByField

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
/**
 * Get a list of things that match a set of keywords from the database.
 * @param field object field to match over
 * @param keywords list of keywords to match.
 * @return A list of things that have matching words in their description.
 */

public List<Thing> getGamesByField(String field, String keywords) {
    ArrayList<Thing> games = new ArrayList<Thing>();
    String search_string = String.format("{\"query\":{\"match\":{\"%s\":{\"query\":\"%s\",\"fuzziness\":\"AUTO\"}}}}", field, keywords);
    io.searchbox.core.Search search = new io.searchbox.core.Search.Builder(search_string)
            .addIndex(ELASTIC_INDEX).addType(ELASTIC_GAME_TYPE).build();
    try {
        SearchResult execute = jestClient.execute(search);
        if (execute.isSucceeded())
        {
            List<Thing> foundGames = execute.getSourceAsObjectList(Thing.class);
            games.addAll(foundGames);
        } else {
            Log.i("TODO", "Search was unsuccessful");
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return games;
}
 
开发者ID:CMPUT301W16T15,项目名称:Shareo,代码行数:27,代码来源:ShareoData.java

示例4: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected ArrayList<User> doInBackground(String... search_parameters) {
    verifySettings();
    ArrayList<User> users = new ArrayList<User>();

    Search search = new Search.Builder(search_parameters[0]).addIndex(INDEX).addType(USER).build();

    try {
        SearchResult result = client.execute(search);
        if (result.isSucceeded()) {
            List<User> foundUsers = result.getSourceAsObjectList(User.class);
            users.addAll(foundUsers);
        } else {
            Log.i("Error", "The search query failed to find users");
        }
    } catch (Exception e) {
        Log.i("Error", "Something went wrong when communicating with the server!");

    }
    return users;
}
 
开发者ID:CMPUT301F16T02,项目名称:Dryver,代码行数:22,代码来源:ElasticSearchController.java

示例5: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected User doInBackground(String... search_parameters) {
    verifySettings();
    String search_string = "{\"from\": 0, \"size\": 1, \"query\": {\"match\": {\"username\": \"" + search_parameters[0] + "\"}}}";

    Search search = new Search.Builder(search_string)
            .addIndex("cmput301f16t01")
            .addType("user")
            .build();

    User foundUser = null;

    try {
        SearchResult result = client.execute(search);
        if (result.isSucceeded()) {
            foundUser = result.getSourceAsObject(User.class);

        } else {
            return null;
        }
    } catch (IOException e) {
        e.printStackTrace();
        Log.i("Error", "Something went wrong when we tried to talk to elastic search");
    }
    return foundUser;
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:27,代码来源:ElasticUserController.java

示例6: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
        protected User doInBackground(String... search_parameters) {
            verifySettings();
            User userResult = null;
            String username = search_parameters[0];
//            Log.d("tag1", "ElasticSearchController: "+username);
            String query = "{\n" +
                    "    \"query\": {\n" +
                    "        \"query_string\" : {\n" +
                    "           \"default_field\" : \"username\",\n" +
                    "               \"query\" : \"" + username + "\"\n" +
                    "               }\n" +
                    "           }\n" +
                    "       }";
            Search search = new Search.Builder(query)
                                    .addIndex(INDEX_NAME)
                                    .addType("user")
                                    .build();
            try{
                SearchResult result = client.execute(search);
                if(result.isSucceeded()){
                    userResult = result.getFirstHit(User.class).source;
                    userResult.setUserID(result.getFirstHit(User.class).id);
                }
            } catch(Exception e){
                Log.i("Error", "Something went wrong when we tried to communicate with the elastic search server!");
            }

            return userResult;
        }
 
开发者ID:CMPUT301F17T23,项目名称:routineKeen,代码行数:31,代码来源:ElasticSearchController.java

示例7: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected ArrayList<Mood> doInBackground(ArrayList<String>... search_parameters) {
    verifySettings();

    ArrayList<Mood> moods = new ArrayList<Mood>();

    for (String sp : search_parameters[0]) {
        String query = "{ \"query\" : { \"filtered\" : { \"filter\" : { \"term\" : { \"owner\" : \"" + sp + "\"}}}}, \"sort\" : { \"date\" : { \"order\" : \"desc\"}}, \"size\" : 1}";

        Search search = new Search.Builder(query)
                .addIndex("cmput301w17t8")
                .addType("mood")
                .build();

        try {
            // get result
            SearchResult result = client.execute(search);
            if (result.isSucceeded()) {
                List<Mood> foundMoods = result.getSourceAsObjectList(Mood.class);
                moods.addAll(foundMoods);
            } else {
                Log.i("Error", "The search query failed to find any mood that matched.");
            }
        } catch (Exception e) {
            Log.i("Error", "Something went wrong when we tried to communicate with the elasticsearch server!");
        }
    }
    Collections.sort(moods, new Comparator<Mood>() {
        @Override
        public int compare(Mood mood, Mood t1) {
            return t1.getDate().compareTo(mood.getDate());
        }
    });
    return moods;
}
 
开发者ID:CMPUT301W17T08,项目名称:Moodr,代码行数:36,代码来源:ElasticSearchMoodController.java

示例8: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected JsonArray doInBackground(String... search_parameters) {
    verifySettings();
    JsonArray userData = null;

    // TODO Build the query
    String query = "{\n" +
            "\"size\" : 1000,"+
            "     \"query\" : {\n" +
            "        \"term\": { \"" + search_parameters[1] + "\": \"" + search_parameters[2] + "\"}\n" +
            "     }\n" +
            "}";

    Search search = new Search.Builder(query)
            .addIndex(INDEX)
            .addType(search_parameters[0])
            .build();

    try {
        // TODO get the results of the query
        SearchResult result = client.execute(search);
        JsonObject hits = result.getJsonObject().getAsJsonObject("hits");
       /* Gson g = new Gson();
        String s = g.toJson(hits);
        Log.d("ESC.json", s);*/
        if (result.isSucceeded()) {
            userData = hits.getAsJsonArray("hits");
        } else {
            Log.i("Error", "The search query failed to find any users that matched");
        }
    } catch (Exception e) {
        Log.i("Error", "Something went wrong when we tried to communicate with the elasticsearch server!");
    }

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

示例9: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
        protected ArrayList<HabitEvent> doInBackground(String... Uids) {

//            Log.i("HabitUpDEBUG", "GetHabitEventsByUidTask");
            verifySettings();

            ArrayList<HabitEvent> habitEvents = new ArrayList<HabitEvent>();

//            Log.i("HabitUpDebug", "Getting Habits for UID " + Uids[0]);

            String query = "{" +
                                "\"size\": " + HabitUpApplication.NUM_OF_ES_RESULTS + "," +
                                "\"from\": 0," +
                                "\"query\": {" +
                                    "\"match\" : " +
                                        "{ \"uid\" : \"" + Uids[0] + "\" }" +
                                "}" +
                            "}";

            Search search = new Search.Builder(query).addIndex(db).addType(habitEventType).build();

            try {
                SearchResult result = client.execute(search);
                if (result.isSucceeded()) {
//                    Log.i("DeBug", "found some habit events");
                    List<HabitEvent> foundHabitEvent = result.getSourceAsObjectList(HabitEvent.class);
                    habitEvents.addAll(foundHabitEvent);

                } else {
                    Log.i("HabitUpDEBUG", "ESCtrl/GetHabitsByUID - result failed");
                }
            }
            catch (Exception e) {
                Log.i("HabitUpDEBUG", "ESCtrl/GetHabitsByUID - exception");
            }

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

示例10: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(String... usernames) {
    verifyClient();
    String search_string = "{\"query\":{\"match\":{\"userName\":\"" + usernames[0] + "\"}}}";


    // NOTE: Only first search term will be used
    Search search = new Search.Builder(search_string).addIndex(teamdir).addType(usertype).build();

    //searchStrings = "{\"from\":0,\"size\":10000, \"sort\": {\"date\": {\"order\": \"desc\"}}}";

    try {
        SearchResult execute = client.execute(search);
        if (execute.isSucceeded()) {
            if (execute.getTotal() > 0){
                return Boolean.TRUE;
            } else {
                return Boolean.FALSE;
            }

        } else {
            return  null;
        }
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:CMPUT301W16T12,项目名称:ProjectFive,代码行数:28,代码来源:ESController.java

示例11: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(String... ids) {
    verifySettings();

    String query =
            "{ \"from\" : 0, \"size\" : 500,\n" +
            "  \"query\": {\n" +
            "    \"bool\": {\n" +
            "      \"must\": { \"match\": { \"_id\": \"" + ids[0] + "\" }},\n" +
            "      \"should\": [\n" +
            "              { \"match\": { \"status\": \"" + Request.Status.OPEN + "\" }},\n" +
            "              { \"match\": { \"status\": \"" + Request.Status.OFFERED + "\" }}\n" +
            "      ],\n" +
            "      \"minimum_should_match\": \"1\"\n" +
            "    }\n" +
            "  }\n" +
            "}";

    Search search = new Search.Builder(query)
            .addIndex("cmput301f16t01")
            .addType("request")
            .build();

    RequestList foundRequests = new RequestList();

    try {
        SearchResult result = client.execute(search);
        if (result.isSucceeded()) {
            List<Request> notificationList = result.getSourceAsObjectList(Request.class);
            foundRequests.addAll( notificationList );
        } else {
            return null;
        }
    } catch (IOException e) {
        e.printStackTrace();
        Log.i("Error", "Something went wrong when we tried to talk to elastic search");
    }

    return foundRequests.size() != 0;
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:41,代码来源:ElasticRequestController.java

示例12: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected ArrayList<Request> doInBackground(String... search_parameters) {
    verifySettings();

    ArrayList<Request> GetAllReqeusts = new ArrayList<Request>();

    int status = 1;
    String search_string = "{\"query\" : {*:*}";
    // assume that search_parameters[0] is the only search term we are interested in using
    Search search = new Search.Builder(search_string)
            .addIndex("f16t14")
            .addType("Request")
            .build();

    try {
        SearchResult result = client.execute(search);
        if (result.isSucceeded()) {
            List<Request> foundRequests = result.getSourceAsObjectList(Request.class);
            GetAllReqeusts.addAll(foundRequests);
        }
        else {
            Log.i("Error", "The search query failed to find any request that matched.");
        }
    }
    catch (Exception e) {
        Log.i("Error", "Something went wrong when we tried to communicate with the elasticsearch server!");
    }

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

示例13: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected ArrayList<Notification> doInBackground(String... search_parameters) {
    verifySettings();
    String search_string = "{\"from\" : 0, \"size\" : 500, \"query\": {\"match\": {\"username\": \"" + search_parameters[0] + "\"}}}";

    Search search = new Search.Builder(search_string)
            .addIndex("cmput301f16t01")
            .addType("notification")
            .build();

    ArrayList<Notification> foundNotifications = new ArrayList<>();

    try {
        SearchResult result = client.execute(search);
        if (result.isSucceeded()) {
            List<Notification> notificationList = result.getSourceAsObjectList(Notification.class);
            foundNotifications.addAll( notificationList );
        } else {
            return foundNotifications;
        }
    } catch (IOException e) {
        e.printStackTrace();
        Log.i("Error", "Something went wrong when we tried to talk to elastic search");
    }

    // If we have a listener, it wants to know if there are unread notifications
    // We will tell the listener in onPostExecute (in case it needs to update a view on UI thread).
    Collections.sort( foundNotifications );
    if (listener != null) {
        for (Notification notification : foundNotifications) {
            if (!notification.isRead()) {
                unreadExists = true;
                break;
            }
        }
    }
    return foundNotifications;
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:39,代码来源:ElasticNotificationController.java

示例14: getAndSetSizeMetrics

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
/**
 * Get and set size metrics.
 * @param indexToInsert
 * @param typeToInsert
 * @param idToInsert
 * @throws IOException 
 */
private void getAndSetSizeMetrics(String indexToInsert, String typeToInsert, String idToInsert) throws IOException {
	String query = "{\n" +
            "    \"query\" : {\n" +
            "        \"match_all\" : {}\n" +
            "    },\n" +
            "    \"aggs\" : {\n" +
            "        \"size_metrics\" : {\n" +
            "            \"extended_stats\" : {\n" +
            "                \"field\" : \"_size\"\n" +
            "            }\n" +
            "        }\n" +
            "    }\n" +
            "}";
		
    Search search = new Search.Builder(query)
            .addIndex(indexToInsert)
            .addType(typeToInsert)
            .build();
    
    SearchResult searchResult = client.execute(search);
    
    if (searchResult.isSucceeded()) {
     ExtendedStatsAggregation sizeMetrics = searchResult.getAggregations().getExtendedStatsAggregation(SIZE_METRICS_PROPERTY);
			
     if (sizeMetrics != null) {
     	if (sizeMetrics.getAvg() != null) {
 			avgInsertSizeBytes.setValue(sizeMetrics.getAvg().longValue());
     	}
     	if (sizeMetrics.getMax() != null) {
     		maxInsertSizeBytes.setValue(sizeMetrics.getMax().longValue());
     	}
     	if (sizeMetrics.getMin() != null) {
     		minInsertSizeBytes.setValue(sizeMetrics.getMin().longValue());
     	}
     	if (sizeMetrics.getSum() != null) {
     		sumInsertSizeBytes.setValue(sizeMetrics.getSum().longValue());
     	}
     }
    }
}
 
开发者ID:IBMStreams,项目名称:streamsx.elasticsearch,代码行数:48,代码来源:ElasticsearchRestIndex.java

示例15: doInBackground

import io.searchbox.core.SearchResult; //导入方法依赖的package包/类
@Override
protected ArrayList<User> doInBackground(String... search_strings) {



    verifyClient();

    // Start our initial array list (empty)
    ArrayList<User> users = new ArrayList<User>();

    if(isOnline()==false){
        return users;

    }

    // NOTE: I'm a making a huge assumption here, that only the first search term
    // will be used.
    String search_string;
    if(search_strings[0] != "") {
        //search_string = "{\"from\" : 0, \"size\" : 10000,\"query\":{\"match\":{\"message\":\"" + search_strings[0] + "\"}}}";
        search_string = "{\"query\":{\"match\":{\"username\":\"" + search_strings[0] + "\"}}}";
    } else {
        search_string = "{\"from\" : 0, \"size\" : 100}";
    }

    Search search = new Search.Builder(search_string)
            .addIndex("warondemand")
            .addType("users")
            .build();

    try {
        SearchResult execute = client.execute(search);
        if(execute.isSucceeded()) {
            // Return our list of tweets
            List<User> returned_tweets = execute.getSourceAsObjectList(User.class);
            users.addAll(returned_tweets);
        } else {
            // TODO: Add an error message, because that other thing was puzzling.
            // TODO: Right here it will trigger if the search fails
            Log.i("TODO", "We actually failed here, searching for users");
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return users;
}
 
开发者ID:Hegberg,项目名称:Agile_Android_Abstracts,代码行数:48,代码来源:DatabaseController.java


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