Message Boards
CompletionSuggester to find search suggestions
CompletionSuggester to find search suggestions
Junior Member Posts: 50 Join Date: 3/31/14 Recent Posts(Liferay 7.2) I have a development in which autocomplete is required in the search input of the SearchBar. To do this, we are implementing a resource that is responsible for obtaining the suggestions as the user writes. Both the spell checker and the PhraseSuggester give me results but not all the expected ones. Also, I don't see how to use a CompletionSuggester.
If I do an index search: http://localhost:9200/_search?pretty=true&q=crisis AND type:querySuggestion
I get this hits:
"hits": {
"total": 2,
"max_score": 11.147705,
"hits": [
{
"_index": "liferay-20101",
"_type": "LiferayDocumentType",
"_id":
"20101_keywordSearch_De/BW/dejFNL0siq+HU2Ew==",
"_score": 11.147705,
"_source": {
"keywordSearch_es_ES": "crisis",
"uid":
"20101_keywordSearch_De/BW/dejFNL0siq+HU2Ew==",
"companyId": "20101",
"groupId":
"0",
"languageId":
"es_ES",
"priority":
"0.0",
"type":
"querySuggestion"
}
},
{
"_index": "liferay-20101",
"_type": "LiferayDocumentType",
"_id":
"20101_keywordSearch_PyewLylt4i0IheiXHaUzgg==",
"_score": 10.469259,
"_source": {
"keywordSearch_es_ES": "La crisis macabea",
"uid":
"20101_keywordSearch_PyewLylt4i0IheiXHaUzgg==",
"companyId": "20101",
"groupId":
"0",
"languageId":
"es_ES",
"priority":
"0.0",
"type":
"querySuggestion"
}
}
]
}
If I check with the PhraseSuggester:
PhraseSuggester suggester = new PhraseSuggester
("phraseSuggester", field, keyword);
suggester.setSize
(5);
[...] = indexSearcher.suggest (searchContext, suggester);
where field = keywordSearch_es_ES and keyword = crisis
The PhraseSuggester only returns the first result, that of a word, but
not the second, which is a phrase.
Without using the Phrase Suggester:
IndexSearcherHelperUtil.suggestKeywordQueries (searchContext, 10);
where in the searchContext.setKeyword ("crisis"), no
results are returned
(If I search for "cirsis", it
does return the result "crisis", so the search by word does it)
In the mapping that Liferay generates, I see that the field where the searches are stored, is of type text, not "completion":
"keywordSearch_es_ES": {
"type":
"text",
"store": true,
"term_vector": "with_positions_offsets",
"analyzer": "spanish",
"search_analyzer": "liferay_analyzer_es"
},
Using the CompletionSuggester on the
"keywordSearch_es_ES", Liferay does not allow me either. And
I don't see another field in the mapping that is of type "completion"
Isn't there a way that, given a word, get all the suggestions,
including sentences, where that word has been used? In the example
above, let the value "crisis" get the phrase hit:
"La crisis macabea
"