Q:

Java - elastic search

Here I'm trying to make a java application and use elasticsearch in the application as a first stage i have made a simple Dynamic Web Java application with spring. In this application(Simple employee records application) I have a privileged login (Admin & User).

Admin - He has all permission 
User - Read and edit permission alone 

I'm trying to make use of elastic search in this application 
Hope you would Help me to make use of the elasticsearch in the application so that I would be able to understand better about the elastic search.

A:

Elasticsearch has provided sufficient number of the java api to get search result by applying query and filters.
Check this link for more details :
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/client.html
        JSONParser parser = new JSONParser();
        JSONObject jsonObject = null;

        Settings s = ImmutableSettings.settingsBuilder()
                .put("cluster.name", SEARCH_CLUSTER_NAME).build();
        SEARCH_CLIENT = new TransportClient(s)
                .addTransportAddress(new InetSocketTransportAddress(
                        SEARCH_HOST, Integer.parseInt(SEARCH_PORT)));

        SearchResponse searchResponse = SEARCH_CLIENT
                .prepareSearch(SEARCH_INDEX_NAME)
                .setScroll(new TimeValue(600000))
                .setTypes(SEARCH_TYPE_NAME)
                .setSearchType(SearchType.SCAN)
                .setQuery(QueryBuilders.matchAllQuery())
                .execute()
                .actionGet();

        while (true) {
            searchResponse = SEARCH_CLIENT
                    .prepareSearchScroll(searchResponse.getScrollId())
                    .setScroll(new TimeValue(600000)).execute().actionGet();
            for (SearchHit hit : searchResponse.getHits()) {

                jsonObject = (JSONObject) parser.parse(hit
                        .getSourceAsString());

            }
            // Break condition: No hits are returned
            if (searchResponse.getHits().getHits().length == 0) {
                break;
            }
        }

