-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change lunr config #168
base: main
Are you sure you want to change the base?
change lunr config #168
Conversation
|
WalkthroughThe pull request introduces modifications to two files: Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
_includes/js/lunr-js.html (1)
24-28
: EnsurefieldValue
is a string before processingTo prevent potential runtime errors, verify that
fieldValue
is a string before callingsplit()
on it. This ensures that only valid strings are processed, avoiding exceptions iffieldValue
is undefined or not a string.Apply this diff:
var fieldValue = store[item][{{ f.field | jsonify }}]; if (fieldValue) { + if (typeof fieldValue === 'string') { // Split semicolon-separated values and join them with spaces indexedData[{{ f.field | jsonify }}] = fieldValue.split(";").join(" "); + } + } else { + // Handle cases where fieldValue is not a string + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- _data/theme.yml (1 hunks)
- _includes/js/lunr-js.html (1 hunks)
🔇 Additional comments (3)
_data/theme.yml (2)
86-86
: LGTM! Configuration change aligns with other child object settings.The change to disable child objects in search results is consistent with the
browse-child-objects: false
setting, maintaining a coherent user experience across browse and search functionalities.
86-86
: Verify the search behavior with this configuration.Since this change affects search results visibility, let's verify the implementation:
✅ Verification successful
Let me try a different approach to verify the search implementation.
This will help us understand where the search functionality is implemented and how configuration values are handled.
Let me check the search implementation files more specifically.
This will help us understand how the search functionality is implemented and whether it respects the
search-child-objects
configuration.
The
search-child-objects
configuration is properly implemented and functionalThe implementation in
assets/js/lunr-store.js
clearly shows that the configuration is respected:
- When
search-child-objects
istrue
, all items are included in the search index:{% if site.data.theme.search-child-objects == true %} {%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%}
- When
false
, only parent objects (items without a parent ID) are included:{% else %} {%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%}Setting it to
false
will exclude child objects from search results, making the search focus only on parent-level items.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the search implementation respects the search-child-objects setting # Test 1: Check if the Lunr search implementation references this config rg -l "search-child-objects" _includes/ # Test 2: Look for any conditional logic handling child objects in search ast-grep --pattern 'if ($CONDITION) { $$$ search $$$ }'Length of output: 103
Script:
#!/bin/bash # Let's check for search-related files and their implementation # Find search-related files fd "search" --type f # Look for search implementation in JavaScript files rg -l "search" --type js # Check for Lunr.js integration rg -l "lunr" --type js # Look for any search configuration handling rg -A 5 "search.*config" --type jsLength of output: 11337
Script:
#!/bin/bash # Check the search implementation files for child objects handling # Check the search layout implementation cat _layouts/search.html # Check the Lunr search navigation implementation cat _includes/nav-search-lunr.html # Look for any JavaScript that might handle the search configuration cat assets/js/lunr-store.jsLength of output: 7074
_includes/js/lunr-js.html (1)
40-40
: Verify case consistency between indexing and queryingThe query is converted to lowercase, but ensure that the indexed data is also in lowercase to maintain consistency and improve search accuracy. If the indexed data maintains original casing, consider removing
.toLowerCase()
or adjusting the indexing process accordingly.Would you like to confirm that the indexed data and search queries are case-consistent?
var result = idx.query(function (q) { | ||
query.split(lunr.tokenizer.separator).forEach(function (term) { | ||
q.term(term, { wildcard: lunr.Query.wildcard.TRAILING }); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle empty or whitespace query terms to prevent errors
When processing the search query, empty strings or terms with only whitespace can cause issues. It's advisable to trim each term and check for emptiness before adding it to the query.
Apply this diff to filter out empty terms:
query.split(lunr.tokenizer.separator).forEach(function (term) {
+ term = term.trim();
+ if (term) {
q.term(term, { wildcard: lunr.Query.wildcard.TRAILING });
+ }
});
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
var result = idx.query(function (q) { | |
query.split(lunr.tokenizer.separator).forEach(function (term) { | |
q.term(term, { wildcard: lunr.Query.wildcard.TRAILING }); | |
}); | |
}); | |
var result = idx.query(function (q) { | |
query.split(lunr.tokenizer.separator).forEach(function (term) { | |
term = term.trim(); | |
if (term) { | |
q.term(term, { wildcard: lunr.Query.wildcard.TRAILING }); | |
} | |
}); | |
}); |
this.pipeline.remove(lunr.trimmer) | ||
this.pipeline.remove(lunr.stemmer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconsider removing lunr.trimmer
and lunr.stemmer
for optimal search performance
By removing lunr.trimmer
and lunr.stemmer
from the pipeline, you may reduce the effectiveness of search queries. The lunr.trimmer
removes unnecessary characters from tokens, and lunr.stemmer
reduces words to their root form, allowing for better matching of different word variations. Consider retaining these processes unless there's a specific reason for their removal.
Apply this diff to keep them in the pipeline:
- this.pipeline.remove(lunr.trimmer)
- this.pipeline.remove(lunr.stemmer);
Committable suggestion was skipped due to low confidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose we put this on hold until we decided on a solution for browse.html
. My research points to a faceted search solution based on lunrjs. I will probably be able to present something mid Nov.
Pull request
Proposed changes
would solve #157. unless we replace the search on the browse page with the lunr search (see #167)
Types of changes
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Documentation