I'm using an Entity Reference field which searches taxonomy terms of type Person to suggest options for autocompletion.

Let's say, i have the following terms (Persons): - Jason Jay Smith - John Jacob Andrews... etc.

When I input "Jason Ja..." in the field, the autocompletion works fine and suggests me the Smith guy. But if i input "Jason Smi...", the term won't be found because the word Jay is skipped. How can i fix this?

Or generally, how can i implement a better autocomplete search? My terms are composed of a number of words and searching by just one word or a fixed word order is definitely not enough

1 Answer 1


Doing this would require a different selection handler. Look at class Drupal\Core\Entity\Plugin\EntityReferenceSelection to see how the default selection handler works. In particular you need to create a different buildEntityQuery method. I don't know of any module that provides a handler to do this, and I'm not sure how I would go about accomplishing it myself. Sorry I can't give a more satisfactory answer.

  • Thanks for the answer, any info is appreciated
    – yesley
    Jun 13, 2019 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.