Ghost Content API Filter Syntax Error

Issue Summary

  • The Ghost Content API is returning a “Request not understood error” when using a combination of tag filters with search terms.
  • I expected the filter to return posts that exclude specific tags AND contain specific search terms in either title or excerpt.

Steps to Reproduce

  1. Create a filter string that combines multiple tag exclusions with title/excerpt search
  2. Use the following filter in a Ghost Content API request: (tag:-changelog+tag:-changelog-new+tag:-changelog-fix+tag:-changelog-improvement+tag:-hash-last9-events)+(title:~'how',excerpt:~'how')
  3. Execute the API request
  4. Observe the BadRequestError response

Relevant log / error output

Error searching blog posts: Error [BadRequestError]: Request not understood error, cannot list posts.
    at C:\Users\Office\Desktop\last9.io\node_modules\@tryghost\content-api\cjs\content-api.js:271:37
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    
context: 'Could not understand request.',
type: 'BadRequestError',
code: 'ER_BAD_FIELD_ERROR'

Additional Information

  • I’ve tried multiple syntax variations following the NQL documentation:
    • Using square bracket notation: tag:-[changelog,changelog-new,changelog-fix,changelog-improvement,hash-last9-events]+(title:~'how',excerpt:~'how')
    • Using parentheses: (tag:-changelog+tag:-changelog-new+tag:-changelog-fix+tag:-changelog-improvement+tag:-hash-last9-events)+(title:~'how',excerpt:~'how')
    • All variations result in the same error
  • According to the documentation, the above syntax should be valid

Since excerpt is a computed field, Ghost doesn’t support filtering on it. To test this, try removing the excerpt portion from your filter (i.e. (tag:-changelog+tag:-changelog-new+tag:-changelog-fix+tag:-changelog-improvement+tag:-hash-last9-events)+(title:~'how'))

Closing in favor of Ghost Content API Bug Report: Excerpt Field Filtering Issue

In the future, please don’t post duplicate or highly similar topics