[DOCS-8014] Comment on: "manual/reference/operator/query/regex.txt" Created: 02/Jun/16  Updated: 03/Nov/17  Resolved: 14/Jun/16

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

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_regex
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.22 Safari/537.36
Referrer: https://docs.mongodb.com/manual/reference/operator/query/
Screen Resolution: 1366 x 768


Participants:
Days since reply: 7 years, 36 weeks, 6 days ago

 Description   

how to find a data such as other DB languange like ,type is int ,not string.



 Comments   
Comment by Ravind Kumar (Inactive) [ 02/Jun/16 ]

Hello,

If you are using MongoDB 3.2+, then you might consider using the $type operator.

$type allows you to evaluate if a field is of a specific BSON type. You can see the supported types here

The $not operator allows you to negate the result of $type to achieve the result you are looking for.

For example, given the following dataset:

    _id : <ObjectId()>
    x : <int, string, or boolean>,

The following query would return documents where x is not a string

    db.collection.find( { "x" : { $not : { $type : "string" } } } )

Similarly, the following query returns documents where X is an int

    db.collection.find( { "x" : { $type : "int" } } )

Please note that MongoDB differentiates between 32-bit integers (int), 64 bit integers (long), and double values. If you wanted to search for values of x that could be an int, long, or double, use the number alias.

Please see this page if you would like more examples to work from.

Generated at Thu Feb 08 07:55:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.