MongoDB $text index and $search for part of word (equivalent to LIKE in SQL) [duplicate]
This question already has an answer here:
mongoDB prefix wildcard: fulltext-search ($text) find part with search-string
6 answers
How to query MongoDB with “like”?
33 answers
I can search for a full word match via the $text and $search methods in MongoDB:
db.users.find({$text: {$search: "John"});
Will results with:
// case sensitive and insensitive - both
{"first_name": "John", "last_name": "Ted", "description": ""}
{"first_name": "Jess", "last_name": "John","description": ""},
{"first_name": "Dan", "last_name": "Brad", "description": "Send the message to John"}
However, I still want to find those results, searching for Joh (note without the full match).
How can I do that?
I have tried:
db.users.find({$text: {$search: {$regex: ".*Joh.*"}}});
I have also tried:
db.users.find({$text: {$search: ".*Joh.*"}});
But that ain't working.
Note - please provide solutions according to $text and $search indexes
mongodb
marked as duplicate by Akrion, Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 '18 at 23:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
mongoDB prefix wildcard: fulltext-search ($text) find part with search-string
6 answers
How to query MongoDB with “like”?
33 answers
I can search for a full word match via the $text and $search methods in MongoDB:
db.users.find({$text: {$search: "John"});
Will results with:
// case sensitive and insensitive - both
{"first_name": "John", "last_name": "Ted", "description": ""}
{"first_name": "Jess", "last_name": "John","description": ""},
{"first_name": "Dan", "last_name": "Brad", "description": "Send the message to John"}
However, I still want to find those results, searching for Joh (note without the full match).
How can I do that?
I have tried:
db.users.find({$text: {$search: {$regex: ".*Joh.*"}}});
I have also tried:
db.users.find({$text: {$search: ".*Joh.*"}});
But that ain't working.
Note - please provide solutions according to $text and $search indexes
mongodb
marked as duplicate by Akrion, Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 '18 at 23:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
You can’t with $text, that’s not how it works.
– Neil.Work
Nov 12 '18 at 23:06
add a comment |
This question already has an answer here:
mongoDB prefix wildcard: fulltext-search ($text) find part with search-string
6 answers
How to query MongoDB with “like”?
33 answers
I can search for a full word match via the $text and $search methods in MongoDB:
db.users.find({$text: {$search: "John"});
Will results with:
// case sensitive and insensitive - both
{"first_name": "John", "last_name": "Ted", "description": ""}
{"first_name": "Jess", "last_name": "John","description": ""},
{"first_name": "Dan", "last_name": "Brad", "description": "Send the message to John"}
However, I still want to find those results, searching for Joh (note without the full match).
How can I do that?
I have tried:
db.users.find({$text: {$search: {$regex: ".*Joh.*"}}});
I have also tried:
db.users.find({$text: {$search: ".*Joh.*"}});
But that ain't working.
Note - please provide solutions according to $text and $search indexes
mongodb
This question already has an answer here:
mongoDB prefix wildcard: fulltext-search ($text) find part with search-string
6 answers
How to query MongoDB with “like”?
33 answers
I can search for a full word match via the $text and $search methods in MongoDB:
db.users.find({$text: {$search: "John"});
Will results with:
// case sensitive and insensitive - both
{"first_name": "John", "last_name": "Ted", "description": ""}
{"first_name": "Jess", "last_name": "John","description": ""},
{"first_name": "Dan", "last_name": "Brad", "description": "Send the message to John"}
However, I still want to find those results, searching for Joh (note without the full match).
How can I do that?
I have tried:
db.users.find({$text: {$search: {$regex: ".*Joh.*"}}});
I have also tried:
db.users.find({$text: {$search: ".*Joh.*"}});
But that ain't working.
Note - please provide solutions according to $text and $search indexes
This question already has an answer here:
mongoDB prefix wildcard: fulltext-search ($text) find part with search-string
6 answers
How to query MongoDB with “like”?
33 answers
mongodb
mongodb
asked Nov 12 '18 at 23:00
RazRaz
243112
243112
marked as duplicate by Akrion, Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 '18 at 23:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Akrion, Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 '18 at 23:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
You can’t with $text, that’s not how it works.
– Neil.Work
Nov 12 '18 at 23:06
add a comment |
You can’t with $text, that’s not how it works.
– Neil.Work
Nov 12 '18 at 23:06
You can’t with $text, that’s not how it works.
– Neil.Work
Nov 12 '18 at 23:06
You can’t with $text, that’s not how it works.
– Neil.Work
Nov 12 '18 at 23:06
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can’t with $text, that’s not how it works.
– Neil.Work
Nov 12 '18 at 23:06