I created a search Index with multiple fields, and I am using the search API programmatically, is there a way to limit the search only on selected fields and not in all of theme?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3039142-4--no_fulltext_fields_query_exception.patch | 2.47 KB | drunken monkey |
Comments
Comment #2
drunken monkeySure: see
\Drupal\search_api\Query\QueryInterface::setFulltextFields().Comment #3
ali-3a commentedThank you it worked,
I tried it befor asking just like it is in the documentation:
$query->setFulltextFields(['title', 'name', 'body']);
I didn't indexed the title or the body (I don't know what is name), and when I didn't get any error I thought that the line was ignored or it has another purpose, I think it should throw an error not just a warning message in the log as I found later:
Search keys are given but no fulltext fields are defined.
Comment #4
drunken monkeyHm, you’re right, a warning is a bit little in that case.
Patch attached, please test/review!
Comment #5
ali-3a commentedLooks great now, Thanks.
Comment #6
laravz commentedThe patch applied successfully to the latest dev. The only change in code is that now a SearchApiException is thrown when the fulltext fields are not defined instead of logging a warning. Seems like an improvement to me.
Comment #8
drunken monkeyGreat to hear, thanks for reviewing!
Committed.
Thanks again!