0

Given:

  • Node type "Article" with fields: title, entity reference field "Related article" to node "Article".
  • The "Related article" field is shown as an "Autocomplete" in the article form.
  • Search API index (Solr) for articles, title field is indexed as fulltext.

Goal:

I would like to be able to have a fulltext search of articles in Autocomplete by Title.

Problem:

I can not achieve this. Is there any existing solution/module to have fulltext search in autocomplete field widget?


Current status

Articles are searched by parts of title, but not with a fulltext search.

A bit of technical research

My initial idea was to use Search API views or query. But the "Autocomplete" widget if provided by the \Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget class, which calls \Drupal\node\Plugin\EntityReferenceSelection\NodeSelection and uses SQL queries. It means have to create a new "Autocomplete" matcher, which processes Search API queries.

I have tried to create an "Entity Reference" Views display for the indexed articles, but it does not appear in the "Related article" field settings as a reference mode, because base table in that view is not "node".

See \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::buildConfigurationForm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.