1

Ok, this might sound simple but am not sure what to do.

I am running PHP 5.3.x and this is what I want to do. I know the find() command. but I am not sure how to rank the returned JSON.

here is how we store our blog

{
"title":"this is a title";
"body":"this is the body";
"author":"ROB"
"keywords":[{'auto';'music';'fun'}]
"country":"USA"
"dateadded":"07-11-2011";
}

what I want to do is the following order Keyword match 100% - 0% Author if author has talked about this keyword a lot there posts go higher up title search score 1 (Meaning matches what user is searching order that by date newest to oldest

please let me know if this is possible.

RussellHarrower
  • 6,470
  • 21
  • 102
  • 204
  • There are related questions on [full text search options with Mongo](http://stackoverflow.com/questions/11015887/mongodb-full-text-search-options) and [full text search indexing](http://stackoverflow.com/questions/737275/comparison-of-full-text-search-engine-lucene-sphinx-postgresql-mysql/737931) that may be helpful. There is also a MongoDB wiki page on [full text search](http://www.mongodb.org/display/DOCS/Full+Text+Search+in+Mongo). – Stennie Jul 01 '12 at 20:59

1 Answers1

2

Mongo is a document store not a search engine. I recommend you look at SOLR to index your documents for search/relevancy and store the documents themselves in mongo. For a blog you can probably forgo mongo and just store everything in SOLR but for large document sets this would be a bad idea.

Kevin
  • 24,871
  • 19
  • 102
  • 158
  • Yeah, I used a blog JSON just so you would understand, this is not really a BLOG just same layout. I really dont want to use SOLR or anything else that requires me to forget mongo and use some different – RussellHarrower Jul 01 '12 at 03:04
  • It will be a large set if around 10,000 collection rows – RussellHarrower Jul 01 '12 at 03:15
  • 10k is small. SOLR does what you want. Mingo doesn't. SOLR is easy don't be afraid. – Kevin Jul 01 '12 at 04:10
  • Well thats 10k in one city now think about * that by how many cities are in the world, and you easy get into the 20M to 40M @kevin – RussellHarrower Jul 01 '12 at 11:03
  • Ok if your data size is 40m then you should index in SOLR and keep content in mongo. – Kevin Jul 01 '12 at 15:34
  • As @Kevin mentions, MongoDB is a document store not a dedicated search engine. You can create some basic search logic using MongoDB features or even implement your own [ranked search](https://gist.github.com/298175), but a search product like [Apache Solr](http://lucene.apache.org/solr/) would include more advanced options like relevance scoring, keyword stemming, and faceted search. Others have also done work to [integrate SOLR with MongoDB](http://stackoverflow.com/questions/6247670/how-do-i-integrate-mongodb-with-solr). – Stennie Jul 01 '12 at 20:59