[SERVER-20516] $text search with $language set to "none" miss some result Created: 21/Sep/15  Updated: 21/Sep/15  Resolved: 21/Sep/15

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.6.7
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: aunz Assignee: Stennie Steneker (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

A collection "test" with the following documents

{name:"green apple"} {name:"red apple"} {name:"banana"}

In the shell, running
db.getCollection('test').find({$text:{$search:"apple"}})
or
db.getCollection('test').find({$text:{$search:"banana"}})
will return results as expected

db.getCollection('test').find({$text:{$search:"banana",$language:"none"}})
will also return 1 result as expected

But
db.getCollection('test').find({$text:{$search:"apple",$language:"none"}})
will return NO result



 Comments   
Comment by Stennie Steneker (Inactive) [ 21/Sep/15 ]

db.getCollection('test').find({$text:{$search:"apple",$language:"none"}})
will return NO result

Hi,

This is actually working as expected since you created the text index using the default stemming (language: "english") and are querying without any stemming (language: "none").

Text search uses the Snowball stemming algorithm, which stems your test words as:

  • apple => appl
  • banana => banana

You'll notice that "banana" does not change so would match in both cases, while "apple" requires the same stemming rule to be applied in the query in order to match what has been indexed. You can check some of the expected Snowball stemming using the online Snowball Demo or by finding a Snowball library for your preferred programming language.

Please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. If you have any follow-up questions on text search indexing, please post on the mongodb-user group.

Thanks,
Stephen

Generated at Thu Feb 08 03:54:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.