Bird
0
0
LLDsystem_design~10 mins

Search functionality design in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the main component responsible for handling search queries.

LLD
class [1] {
    public void handleSearch(String query) {
        // Implementation
    }
}
Drag options to blanks, or click blank then click option'
ASearchHandler
BQueryProcessor
CSearchEngine
DResultFetcher
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a class name that implies fetching results instead of handling queries.
Using a generic name that does not clearly indicate its role.
2fill in blank
medium

Complete the code to add a method that indexes documents for search.

LLD
public class Indexer {
    public void [1](Document doc) {
        // Indexing logic
    }
}
Drag options to blanks, or click blank then click option'
AindexDocument
Bsearch
CfetchResults
DprocessQuery
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names related to searching instead of indexing.
Choosing vague method names that do not describe the action.
3fill in blank
hard

Fix the error in the code that processes search queries asynchronously.

LLD
public class AsyncSearchProcessor {
    public Future<List<Result>> processQuery(String query) {
        return executorService.[1](() -> {
            // Search logic
            return search(query);
        });
    }
}
Drag options to blanks, or click blank then click option'
Ainvoke
Bexecute
Crun
Dsubmit
Attempts:
3 left
💡 Hint
Common Mistakes
Using execute which returns void, causing a type mismatch.
Using run or invoke which are not methods of executorService.
4fill in blank
hard

Fill both blanks to complete the code for filtering search results by relevance and date.

LLD
List<Result> filteredResults = results.stream()
    .filter(r -> r.getRelevance() [1] 0.8)
    .filter(r -> r.getDate() [2] LocalDate.now().minusDays(30))
    .collect(Collectors.toList());
Drag options to blanks, or click blank then click option'
A>=
B<=
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators that exclude desired results.
Mixing up greater than and less than for date filtering.
5fill in blank
hard

Fill all three blanks to complete the code that builds a search query with filters and sorting.

LLD
SearchQuery query = new SearchQuery.Builder()
    .setKeyword([1])
    .addFilter([2], [3])
    .setSortOrder(SortOrder.RELEVANCE)
    .build();
Drag options to blanks, or click blank then click option'
A"machine learning"
B"date"
C"last_30_days"
D"popularity"
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated filter fields or values.
Setting keyword to a filter value instead of a search phrase.