[SERVER-27561] Should a text query for 'leaderboard' match 'leader-board'? Created: 03/Jan/17  Updated: 27/Oct/23  Resolved: 03/Jan/17

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Text Search
Affects Version/s: 3.4.0
Fix Version/s: None

Type: Question Priority: Trivial - P5
Reporter: Cyril Auburtin Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

I was surprised by the last line:

> db.y.find()
> db.y.createIndex({name:'text'})
{
        "createdCollectionAutomatically" : true,
        "numIndexesBefore" : 1,
        "numIndexesAfter" : 2,
        "ok" : 1
}
> db.y.insert({name:'leader-board'})
WriteResult({ "nInserted" : 1 })
> db.y.find({$text:{$search:'leader'}})
{ "_id" : ObjectId("586b69d30c34db31e74c6413"), "name" : "leader-board" }
> db.y.find({$text:{$search:'leader board'}})
{ "_id" : ObjectId("586b69d30c34db31e74c6413"), "name" : "leader-board" }
> db.y.find({$text:{$search:'leader-board'}})
{ "_id" : ObjectId("586b69d30c34db31e74c6413"), "name" : "leader-board" }
> db.y.find({$text:{$search:'leaderboard'}})

Shouldn't it still match it? I understand in general 'foo-bar' and 'foobar' are not synonyms, but are there ways to associate those terms in some conditions, other than putting both terms?



 Comments   
Comment by Kelsey Schubert [ 03/Jan/17 ]

Hi caub,

This is the expected behavior as the hyphen-minus (-) character is treated as a delimiter. For additional details, please review our documentation here and here. It is not possible to match a search term of "foobar" to the document containing "foo-bar".

For MongoDB-related support discussion please consider posting on the mongodb-users group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group.

Kind regards,
Thomas

Comment by Cyril Auburtin [ 03/Jan/17 ]

other example:

> db.y.insert({name:'e-book'})
> db.y.find({$text:{$search:'ebook'}})
>

Generated at Thu Feb 08 04:15:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.