Auto-complete List Results filtering - for a one-to-many field

Our front-desk officer selects from the list of Products by searching through typing. Consider following six options:

Hepatitis B Virus (HBV)
Hepatitis B Virus (HBV DNA Quantitative) - PCR
Hepatitis B Virus (HBV DNA Qualitative) - PCR
Hepatitis C (HCV)
Hepatitis C Virus (HCV RNA)(Qualitative) - PCR
Hepatitis C Virus (HCV RNA) (Quantitative) - PCR

In order to search for the second product “Hepatitis B Virus (HBV DNA Quantitative) - PCR”, he has to type “Hepatitis B Virus (HBV DNA quan” then the maximum-filtered result appears.

What the user wants is to type ‘HBV PCR’, and the auto-complete list shows all those records containing ‘HBV’ or ‘PCR’ in the title at any position. Can it be done? If so, which method of Product class needs to be changed?

In fact, we have products which have many words matching to each other. We want to filter the results in the auto-complete based on the words typed in any order rather than the order in which they actually appear - as the user is unaware of the actual order of words in the name.

Best Regards,
Khurram.

The completion uses a domain like [('rec_name', 'ilike', '%whatever%')] thus you should override the search_rec_name method.

This looks like a good fit for a trigram index:

Another option is to ask user to make they search by typing: “%HBV%PCR%”
But the order will still be enforced

Dear Nicoe,

Thank you so much for your response; I will try these options and will get back.

Best Regards,
Khurram.

Dear Ced,

Thanks; but some valid records may be skipped from search results if the order is enforced!

Regards.