0

For e.g , I have text file stored in GridFS & I want to check for Text 'Germany' in File for its presence

Any idea?

  • It's just a collection. Likely `db.fs.files.find()` will show you something unless you changed the namespace. Query on any property you want as normal. – Blakes Seven Jul 23 '15 at 10:43
  • Sry, But I want to Query Chunks data, ANd data we store in CHunks is of Binary type. SO how to query it? – Vaibhav Jul 23 '15 at 10:44
  • 1
    You cannot do that without reading the entire "file" content and parsing it. – Blakes Seven Jul 23 '15 at 10:44
  • Please do not attempt to past code in comments. If you feel you have something to add to your question the use the "Edit" link provided there. You cannot ask the server to "search" for text in a gridFS object which is stored in binary format. If you want to do that then extract the text and put that text in another collection, where you can use a text index to search. – Blakes Seven Jul 23 '15 at 10:51
  • You mean to say extract chunks and store it in another Collection? Can you please put some light over here. Is there any way we can achieve this using Pymongo? – Vaibhav Jul 23 '15 at 11:01
  • The GridFS chunk data is binary. If you want to index the contents of a file saved in GridFS you'll need a different approach such as saving keywords in the GridFS file metadata or perhaps extracting the text to a separate collection. If your text files are less than 16MB (the current maximum document size in MongoDB), you could always store the text directly as a MongoDB document. For an example of using GridFS metadata see the MongoDB manual: [Metadata and Asset Management](http://docs.mongodb.org/ecosystem/use-cases/metadata-and-asset-management/). – Stennie Jul 27 '15 at 05:57

0 Answers0