Get values with specific characters


(JavaES) #1

Hi Team,

how to get the matches in the index with specific words..

Actually i have polyurethane in my elastic search ,

I want to get this word in otput if the user types more than two words in search box ..

If he types pol i want polyurethane to populate

M using the following code ,how i need to modify my code

//QueryBuilder builder = new QueryBuilder();
final TimeValue timeValue = TimeValue.timeValueMillis(10000);

	try {
		
		// getting suggestion for SAYT search term
		CompletionSuggestionBuilder suggestionsBuilder = new CompletionSuggestionBuilder("complete");
		suggestionsBuilder.text(queryTerm);
		//JSONArray blackListArr = new JSONArray();
		suggestionsBuilder.field("autocomplete");		
		builder.must(QueryBuilders.matchQuery("suggestion", queryTerm).operator(MatchQueryBuilder.Operator.AND).fuzziness(Fuzziness.ONE));
		//builder.must(QueryBuilders.queryStringQuery(queryTerm).field("suggestion").fuzziness(fuzzinessValue));
		SearchRequestBuilder srb = ClientInstance.getInstance().getClient().prepareSearch(index).setTypes(type).setTimeout(timeValue).setQuery(builder);
		
		//.addSuggestion(suggestionsBuilder);
		srb.setSize(15);
		SearchHits hitss = null;
		SearchHit hittss = null;
		SearchHits totalhitss = null;
		SearchResponse response = srb.execute().actionGet();
		total = response.getHits().getTotalHits();

(system) #2