0

I'm using mongodb 2.4 and added fulltext index to the "title" field in one the collection. How should I search something in that field using php?

This is the code I use right now:

$params = array(
        '_id' => array(
            '$gt' => (int)$gt
        )
    );
$r = $this->collection->find( $params )->limit($limit);
3
  • link one on a google search: blog.mongohq.com/blog/2013/01/22/… Commented Apr 17, 2013 at 22:04
  • Might be duplicate question: Here's an example:[link] (stackoverflow.com/questions/15313805/…) Commented Apr 17, 2013 at 22:18
  • 1
    @Dagon That link doesn't mention PHP at all Commented Apr 18, 2013 at 5:47

1 Answer 1

1

This seem to be the answer to my question:

<?php
$result = $db->command(
    array(
        'text' => 'bar', //this is the name of the collection where we are searching
        'search' => 'hotel', //the string to search
        'limit' => 5, //the number of results, by default is 1000
        'project' => Array( //the fields to retrieve from db
            'title' => 1
        )
    )
);

http://www.php.net/manual/en/mongodb.command.php#111891

Sign up to request clarification or add additional context in comments.

1 Comment

I got result like string(21) "no such command: text" text is not taking as collection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.