[DOCS-11632] Text Search not working properly Created: 17/Apr/18  Updated: 17/Apr/18  Resolved: 17/Apr/18

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Rahul Raj Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates DOCS-10382 Clarify if MongoDB text search is cor... Closed
is duplicated by SERVER-34521 Text Search not working properly Closed
Participants:
Days since reply: 5 years, 43 weeks, 1 day ago

 Description   

https://docs.mongodb.com/manual/text-search/
As per the docs, when I hit the query:

db.sample.find({ $text: { $search: "cakes \"coffee shop\"" } })

It should return all documents containing "coffee shop" OR "cakes". So it should return both documents. But it isnt happening. Contradicting to the definition given on the docs, it return only one doc from the data set:

{
    "_id" : ObjectId("5ad609baac1a8b644180936b"),
    "content" : "coffee shop..."
}

Here is the full data set:

/* 1 */
{
    "_id" : ObjectId("5ad609a2ac1a8b644180936a"),
    "content" : "Coffee and cakes..."
}
 
/* 2 */
{
    "_id" : ObjectId("5ad609baac1a8b644180936b"),
    "content" : "coffee shop..."
}

Text index was already created for the field "content". Results are contradicting the definition (under Exact Phrase) text search docs:



 Comments   
Comment by Kelsey Schubert [ 17/Apr/18 ]

Thanks for identifying this issue, rahulraj.

As you correctly note, there is an inconsistency in the documentation between these two pages. We're tracking this fix to the documentation in DOCS-10382.

https://docs.mongodb.com/manual/reference/operator/query/text/#phrases correctly describes the current implementation of this feature.

Kind regards,
Kelsey

Comment by Rahul Raj [ 17/Apr/18 ]

One more thing to point out that I found another docs reference where it say it will do an AND : https://docs.mongodb.com/manual/reference/operator/query/text/#phrases
Actually an AND query is happening, but then why its mentioned as OR in docs here: https://docs.mongodb.com/manual/text-search/ . Also why its not happening even if I have text index in place? If not, whats is the definition of a valid OR case to happen?

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