setTypes ignored on Completion search


Here is my code:

CompletionSuggestionBuilder completionSuggestionBuilder = SuggestBuilders.completionSuggestion("suggest");

    if (isEmpty(searchString)) {"Adding regex");
    } else {"Adding search string as prefix");

    SuggestBuilder suggest = new SuggestBuilder().addSuggestion(suggestionName, completionSuggestionBuilder);"Suggest search on Index [" + INDEX_NAME + "] and types set to [" + resourceDefinitionId.getId() + "]");

    SearchRequestBuilder searchRequestBuilder = transportClient.prepareSearch(INDEX_NAME).setTypes("myId").suggest(suggest);"searchRequestBuilder is " + searchRequestBuilder.toString());

    SearchResponse searchResponse = searchRequestBuilder.get();
    SearchHits hits = searchResponse.getHits();

But I get hits back that are not of the supplied type. Is this expected behaviour?


yes, the completion suggester takes the whole index into account.

You can however use the context suggester to filter for documents in an index (also allowing the for the type)


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.