Discussion:
[MongoDb 4.0] TextSearch confusion
(too old to reply)
Thai Anh Vu
2018-11-27 10:43:07 UTC
Permalink
Hi guys,

I'm quite confused with the TextSearch result from Mongodb and hope you
guys can help shed some light on this.

Here is my test scenario.

I created a collection called "Test" and then i added 2 documents into it {
Name: "Active" }, {Name: "Activate"}. I also created a text index on the
field "Name" as well.

First, i ran db.Test.find({$text: {$search: "Active"}}, {score: {$meta:
"textScore"}}).pretty(). I expected 1 document returned, which is { Name:
"Active" } but actually both documents were returned.

Next, i ran db.Test.find({$text: {$search: "Activ"}}, {score: {$meta:
"textScore"}}).pretty(). I expected nothing returned, but again both
documents were returned.

Finally, i ran db.Test.find({$text: {$search: "Acti"}}, {score: {$meta:
"textScore"}}).pretty(). This time, nothing was returned which i expected.

I don't understand how MongoDb processed the 2 first queries. Can you help
clarify this or give me some links that i can look into myself? I have read
the TextSearch on Mongo documents but haven't found a clue (perhaps i may
have overlooked).

Thank you,
Anh
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/561338cd-0a8a-4e4b-b9f1-c3097129daa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sandeep Singh
2018-11-28 07:40:13 UTC
Permalink
Hi,
Search is actually performed on the stemmed word, so in your case you will
get the same word at the end.
Stemmed word for "Activate" and "Active" is the same i.e. "Activ".
The term "Acti" did not give you anything because there were no documents
matching the criteria.

--
Sandeep
Post by Thai Anh Vu
Hi guys,
I'm quite confused with the TextSearch result from Mongodb and hope you
guys can help shed some light on this.
Here is my test scenario.
I created a collection called "Test" and then i added 2 documents into it
{ Name: "Active" }, {Name: "Activate"}. I also created a text index on the
field "Name" as well.
"Active" } but actually both documents were returned.
"textScore"}}).pretty(). I expected nothing returned, but again both
documents were returned.
"textScore"}}).pretty(). This time, nothing was returned which i expected.
I don't understand how MongoDb processed the 2 first queries. Can you help
clarify this or give me some links that i can look into myself? I have read
the TextSearch on Mongo documents but haven't found a clue (perhaps i may
have overlooked).
Thank you,
Anh
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-user/561338cd-0a8a-4e4b-b9f1-c3097129daa6%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/561338cd-0a8a-4e4b-b9f1-c3097129daa6%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAAjZhnDP2H-W45R7ngF1XaxUTo%3DXzm%3DWeMudW87rEkA795_RXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...