質問

i am investigating the autosuggest behavior of solr, but i'd like to accomplish the following:

As the user types sth. in, an autosuggest shall provide "grouped" information - including indexed data. For instance typing "Op" may suggest "OpenLayers" and "Opodo", which both are part of the index, but are different in terms of "type". In result, rather than just suggesting the word to client, i'd like to provide meta information for all possible suggested words, being grouped by "type".

E.g.

Textfield: [Op ]

Suggestion:

[Websites] Opodo

###

[Framework] OpenLayers

Another solution would be, defining another query to solr with all suggestions, group those and then deliver view to client. However it would be great to not be forced to query solr multiple times, if it may not be necessary.

I also wonder, if instead of suggesting the words, just querying userinput via xx*, interpreting these and deliver view may be a proper way to get what i want.

Thanks in advance.

役に立ちましたか?

解決

If you want to show more metadata with the results, You need to Query the results instead of autosuggest.
And if you just want the autocomplete, you can check for EdgeNGramFilter.

<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="30"/> will generate ngram tokens which would be at separate positions.

e.g. Opodo with generate -> op, opo, opod, opodo ....

This field can be used for the autocomplete by query on the the field.
you can include the other metadata into the results and group them on client side.

Wildcards would be expensive as it is query time. Also no analysis are performed for wildcard queries.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top