nqxcode / laravel-lucene-search

Laravel 4.2, 5.* package for full-text search over Eloquent models based on ZF2 Lucene.
73 stars 28 forks source link

How to get searched data from builder object. #45

Closed nitusahuglobussoft closed 7 years ago

nitusahuglobussoft commented 7 years ago

I am using laravel 5.2 version. Proceeded by the over all doc. I am trying to search the related data from my mysql DB.

Here is my code of model.

<?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Auth\User as Authenticatable; use Nqxcode\LuceneSearch\Facade as Search; use Nqxcode\LuceneSearch\Model\SearchableInterface; use Nqxcode\LuceneSearch\Model\SearchTrait;

class User extends Authenticatable implements SearchableInterface { use SearchTrait; public function getSerarchName(){ $query = Search::where('name', 'nitu'); return $query; } } ?>

But I am getting this type of output.

Builder {#455

runner: Runner {#459

-search: Search {#330
  -connection: Connection {#331
    -index: Index {#369
      -_directory: Filesystem {#366
        #_dirPath: "D:\LaravelProject\newstart\storage\app/lucene-search/index"
        #_fileHandlers: array:11 [
          "read.lock.file" => Filesystem {#365
            #_fileHandle: stream resource @284
              timed_out: false
              blocked: true
              eof: false
              wrapper_type: "plainfile"
              stream_type: "STDIO"
              mode: "w+b"
              unread_bytes: 0
              seekable: true
              uri: "D:\LaravelProject\newstart\storage\app/lucene-search/index/read.lock.file"
              options: []
            }
          }

How can i get the search result ? Like: if I am searching for "nitu" the output will be like "nitu sahu", "nitu jha" "nitu mishra" Am i going in a right way ?

nqxcode commented 7 years ago

You should use get() or paginate() methods, see in https://github.com/nqxcode/laravel-lucene-search#getting-of-results.