I am new to Drupal. I'm trying to implement advanced search on my Drupal8 website. It's working perfectly with the logical operator 'OR' and 'AND' but not with 'NOT', '+', '-'.

Here is my request :

$index = \Drupal\search_api\Entity\Index::load('videos_full');
    $query = $index->query();
    $parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')
    $query->addCondition('search_api_language', \Drupal::languageManager()->getCurrentLanguage()->getId());

    $query->setFulltextFields(['field_title', 'title', 'resourcetype', 'tag', 'choreographer', 'director', 'producer', 'structure', 'contributor', 'secondaryauthor']);

    $results = $query->execute();

Thank you for your help !


Please refer to following Drupal documentation example for advanced configuration of search query:



'+', '-' works by default in $search(searched keyword)

Your Answer

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

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