plurals and words ending in double-el
See original GitHub issueWhen I search for a term that’s indexed by its plural, i.e. “carols”, I get no hits. Searching for “carol” or “carol*” works perfectly, but “carols”, “carols*” or “carols” comes up empty. Another example would be “Schwitters”. A search for “schwitter” gets a hit, but “schwitters” doesn’t.
I have a similar problem where searching for “powell” yields no results, but “powel” works as expected.
I did some basic testing and it seems to only apply to words ending in two els. If I change “powell” to “powerr” searches succeed.
This happens with v2.0.4 and also v2.1 Any idea what’s going on here?
This is how I build the index
let index = lunr(function() {
this.field("title", {boost: 10});
this.field("section");
this.field("content");
this.field("worknumber");
this.field("meta");
this.field("description");
this.field("firstname");
this.field("lastname");
this.field("tags");
this.ref("ref");
pages.forEach(page => {
this.add(page);
})
});
and the search (I fiddled with usePipeline
but it seems to have no effect)
let results = index.query(function(q) {
q.term(term, {
fields: fields,
usePipeline: false,
})
});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Definitions and examples of double plurals in English
A double plural is the plural form of a noun with an additional plural ending (usually -s) attached; for example, candelabras (singular, ...
Read more >Spelling Rules: Drop the 'f' and add 'ves' to make plurals
Spelling Rules: Plural Rule #4 If the noun ends with ‑f or ‑fe, the f is often changed to ‑ve before adding the...
Read more >Spelling Rule Rap: Add 'ies' to make plurals with ... - YouTube
A song about making plurals of words that end in 'y'If a word ends consonant 'y' don't stressChange the 'y' to an 'i'...
Read more >Developers - plurals and words ending in double-el - - Bountysource
When I search for a term that's indexed by its plural, i.e. "carols", I get no hits. Searching for "carol" or "carol" works...
Read more >Spelling - Grammar - Cambridge Dictionary
When we add a suffix to a word with more than one syllable, we double the consonant only when the word ends in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
First off, that fiddle works for me on Safari 10.1.
So, it looks like you are trying to implement a typeahead style search. By manually appending the wildcard to the term, lets say “carols*”, you are searching for everything that begins with “carols” and then has some other characters after it. In addition you are not disabling the pipeline, so lunr is trying to trim and stem “carols*” with the wildcard, which probably isn’t doing anything.
I think the right way to approach this kind of search is to think of it in two parts:
So, in your case if you switch to the following:
You should get better results as well as getting results for “carols”, in your example. I’ve updated the fiddle with this change. Now, depending on what you want to do you can take it further by also doing a fuzzy search, this time with an even smaller boost:
You’ll have to experiment to see what works best for your application, but hopefully this is enough to get you on the right track.
@olivernn I know this is an old thread, but I’ve had similar confusions for getting matches on singular and plural terms. I’ve noticed the fiddle you updated only produces results when searching for single words. Ex: ‘carol’
But if I search any more, ex: ‘carol notes’ I get no matches.
Is there a way to use your settings but also to include matches for multiple terms?