Hi,
Please see my reply below.
On Apr 9, 9:01 pm, yuan <
huapengy...@gmail.com> wrote:
> Hi:
>
> I have a couple of questions about GenericTypeahead after looked at
> the code of cleo.
>
> (1) Looks like GenericTypeahead return all of matched elements. Is
> this correct?
> If it is true, what if a key(term) are matched with lots of
> elements? For example, 1 million. It will comsumes lots of memory and
> increase latence.
This really depends on the type of Collector you are using. There are
several different types Collector you can use to return over 1 million
elements or top 10 elements. Choose the collector that suits your
needs.
>
> (2) In the indexDataStore, looks like elements are not sorted by
> score. Also, the seach() function has a paramter timeoutMillis.
> What if the function search() reutrn earlier because of
> timeoutMillis, can GenericTypeahead guarntee return elemetns with
> the highest score?
For typeahead, as a user is typing more characters, the search scope
is narrowing down quickly. The timeoutMillis is for early termination
to guarantee response time but not full coverage. If your program
really need to find the elements with the highest score, you should
NOT consider using timeout.