0

The below list have in my Collection. Field name is list_name with text index.

  1. DEMOSTAT 200 MG TABLET SR
  2. DEMOWIN 200 MG TABLET SR
  3. DEMOBEST OD 200MG TABLET
  4. DEMOBEST SR 200MG TABLET
  5. DEMOCHEK 200MG TABLET SR
  6. DEMOKIND -SR 200MG TABLET

Below is my Query

$arraySch = array('$text'=>array('$search'=>"\"DEMO\" \"200\""));

$arrData = $this->mongo_db->where ($arraySch)->get('list');

The below two list only comming

  • DEMOSTAT 200 MG TABLET SR
  • DEMOWIN 200 MG TABLET SR

Not coming the below

  • DEMOBEST OD 200MG TABLET
  • DEMOBEST SR 200MG TABLET
  • DEMOCHEK 200MG TABLET SR
  • DEMOKIND -SR 200MG TABLET

Let me know why? And No result to below search

$arraySch = array('$text'=>array('$search'=>"\"DEMOB\""));

Sailesh Guna
  • 1
  • 1
  • 3
  • http://stackoverflow.com/questions/21018738/mongodb-fulltext-search-workaroud-for-partial-word-match – bauman.space Feb 28 '17 at 14:16
  • Using MongoDB text search not working perfectly. POLO should match "POLOBEST P 100MG/500MG TABLET" this but not matching. When I search with "POLOBEST" then matching above – Sailesh Guna Mar 01 '17 at 04:42
  • default text search doesn't do partial words, you'll need to use a regex match. – bauman.space Mar 01 '17 at 14:48

1 Answers1

0
$search_text = 'DEMO';
$search_details = $this->mongo_db->select('*')->like('list_name',$search_text,'i', true, true)->get('list');
Puneeth Kumar
  • 182
  • 2
  • 14