0

I have a MongoDB database with lots of text, my client wants to search in it with:

LIKE "%term%"

is there any full text search engine that could index such searching? P.S : I'm using php and MongoDB.

Ehsan Zargar Ershadi
  • 24,115
  • 17
  • 65
  • 95
  • http://stackoverflow.com/questions/3305561/how-to-query-mongodb-with-like/3305687#3305687 – WiredPrairie Apr 27 '13 at 00:02
  • Or try a full text search engine solution, like Solr or ElasticSearch – WiredPrairie Apr 27 '13 at 00:02
  • how can i know which one is best for mongodb – Ehsan Zargar Ershadi Apr 27 '13 at 00:18
  • 1
    Which is the best for MongoDB? THey're both powered by Lucene underneath, so you'll need to export your data if you need something more complex than using Regular Expressions as was documented in the link I added. – WiredPrairie Apr 27 '13 at 00:45
  • If you're using regular expressions for a small dataset it's probably fine. However, regex doesn't use indexes so it's both slow and expensive and should not be used on big datasets in production. – xeraa Apr 28 '13 at 22:35

2 Answers2

0

The below Query will fetch exact word $term from the DB table coulmn value.

SELECT * FROM sometable WHERE somefield LIKE '% $term %' OR somefield LIKE '$term %' OR somefield LIKE '% $term'
Jenson M John
  • 5,499
  • 5
  • 30
  • 46
  • This is not what i meant, 1) this is not a syntax for MongoDB, 2) it is very slow in a huge database with 40GB of text, 3) I'm seeking for some sort of indexing – Ehsan Zargar Ershadi Apr 27 '13 at 00:01
0

http://docs.mongodb.org/manual/core/text-search/ might be of interest to you. This is new in MongoDB 2.4 and it includes support for text index. It appears that this is currently a beta feature, though.

MervS
  • 5,724
  • 3
  • 23
  • 37