Parse and Evaluate Advanced Search Filters for Tasks

Last updated: November 29, 2026

Quick Overview

Implement a parser for search queries like `assignee:me AND (tag:urgent OR NOT completed:true)` and return the tasks that match. Support AND, OR, NOT, parentheses, quoted values and implicit AND between adjacent terms.

Asana
Coding & Algorithms
Software Engineer
Asana
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Implement a parser for search queries like `assignee:me AND (tag:urgent OR NOT completed:true)` and return the tasks that match. Support AND, OR, NOT, parentheses, quoted values and implicit AND between adjacent terms.

Asana's advanced search lets people filter by assignee, tags, completion and text, and power users expect boolean logic to just work. This is a long-form onsite exercise in the practical, build-something style Asana favors: the interviewer looks for a clean tokenizer, correct precedence, and useful errors.

What the Interviewer Expects
  • Separates tokenizing from parsing
  • Writes a grammar with NOT binding tighter than AND, and AND tighter than OR
  • Implements recursive descent producing a small AST
  • Evaluates the AST against tasks with a field dispatcher
  • Reports syntax errors with position instead of returning wrong results
Key Topics to Cover
recursive descent parsing
tokenization
operator precedence
abstract syntax trees
error handling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you turn the AST into a database or search-index query instead of filtering in memory?
  • How would you add `due:<2026-12-01` style comparisons?
  • How would you rewrite the AST to make NOT cheap to execute?
  • How would you give the user autocomplete while typing a query?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Terms are field:value with fields assignee, tag, completed, name; values may be quoted. me resolves to the current user. Operators are uppercase AND, OR, NOT. Adjacent terms mean AND. Malformed qu...

High-Level Design

A regex tokenizer emits parentheses, operators and TERM tokens. A recursive descent parser follows the grammar expr := and (OR and)*, and := unary (AND? unary)*, `unary := NOT unary | ( expr ) | T...


Submit Your Answer
Markdown supported

Related Questions