Giter VIP home page Giter VIP logo

laravel-scout-elastic's People

Contributors

bbashy avatar beingjungshahi avatar briangreenhill avatar casperlaitw avatar clsource avatar dmitrakovich avatar ericktamayo avatar fridzema avatar kronthto avatar lloy0076 avatar macghriogair avatar pooyadustdar avatar prajapatinirav avatar pvanhemmen avatar semyonchetvertnyh avatar shibby avatar tillkruss avatar xcaptain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-scout-elastic's Issues

Not working with my version of Laravel Scout ?

Hi, the search() method does not work on the indexed model. The searchable() method does not either. Here is the query in my controller:

public function search(Request $request){

            $articles = Article::search($request->input('search'))->get();
     
        return view('Articles.searchResult', compact('articles'));

    }

It always returns all objets in the collection.

I use Laravel 5.3, with Scout 2.0, Elastic Search 5.2 and laravel-scout-elastic 2.0.0

Here is an excerpt of my file composer.json :

"require": {
        "php": ">=5.6.4",
        "elasticsearch/elasticsearch": "^5.2",
        "laravel/framework": "5.3.*",
        "tamayo/laravel-scout-elastic": "~2"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.0",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*",
        "laravel/scout" : "^2.0"
    },

Could you help me please ? Thanks in advance

"Fuzzy" requests

Hello! Could you help me, how can I use laravel-scout-elastic with fuzzy search, like this:

curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'

{
"query": {
"fuzzy" : { "name" : "нjальник" }
}
}
'

Query String Query Wildcard?

When using this package fresh, I cannot get search results, but after changing this line

https://github.com/ErickTamayo/laravel-scout-elastic/blob/3.0.1/src/ElasticsearchEngine.php#L134

to following:

'must' => [['query_string' => [ 'query' => "\*{$builder->query}\*"]]]

it works.

I've read on elasticsearch official doc that the * in query string query should be escaped, am I right here?

I'm new to both Scout and this package, so maybe it's just me using it wrongly.
But If this is the right way to fix, I'd love to offer a PR as well.

How can I set the created_at field type as date?

I have a searchable model which has the standard created_at and updated_at fields. When I run
curl -XGET 'localhost:9200/laravel/_mapping/my_table?pretty', these two fields are both "text" type.

 "created_at" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              }

Is there a way to save them as date type? Thanks.

Any good ideas how to implement count results?

I need to be about to count the ES hits, currently I am doing this:

trait ElasticCountable
{
    public static function elasticCount($filters)
    {
        $model = new static();
        $host = config('elasticsearch.hosts');
        $client = ClientBuilder::create()->setHosts($host)->build();
        $params = [
            'index' => $model->searchableWithin(),
            'type' => $model->searchableAs(),
            'body' => [
                'query' => [
                    'bool' => $filters
                ]
            ]
        ];
        return $client->count($params)['count'];
    }

Models that are elaticCountable can then do:

Article::elasticCount(['must' => ['term' => ['is_published' => true]]])

The elasticCount is very flexible, but not fluent, and doesn't utilize Scout. Any ideas?

New Release

Hi,

Could you do a new release to publish the new changes?

Filter Use install of additional must bool statements

I think you would use the filter part of the bool query instead of matching additional match_phrase when using the where method.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

I think the code should be updated to use filters like so -

    protected function performSearch(Builder $builder, array $options = [])
    {
        $params = [
            'index' => $this->index,
            'type' => $builder->index ?: $builder->model->searchableAs(),
            'body' => [
                'query' => [
                    'bool' => [
                        'must' => [['query_string' => [ 'query' => "*{$builder->query}*"]]]
                    ]
                ]
            ]
        ];

        if ($sort = $this->sort($builder)) {
            $params['body']['sort'] = $sort;
        }

        if (isset($options['from'])) {
            $params['body']['from'] = $options['from'];
        }

        if (isset($options['size'])) {
            $params['body']['size'] = $options['size'];
        }

        if (isset($options['numericFilters']) && count($options['numericFilters'])) {
            $params['body']['query']['bool']['filter'] = [];
            $params['body']['query']['bool']['filter'] = array_merge($params['body']['query']['bool']['filter'],
                $options['numericFilters']);
        }
        return $this->elastic->search($params);
    }

    /**
     * Get the filter array for the query.
     *
     * @param  Builder  $builder
     * @return array
     */
    protected function filters(Builder $builder)
    {
        return collect($builder->wheres)->map(function ($value, $key) {
            return ['term' => [$key => $value]];
        })->values()->all();
    }

Question about asterisk surrounding query string

I'm still learning Laravel and Elasticsearch.

When I tried searching using GET commands directly to my Elasticsearch server and compared to using Laravel Scout with your engine, I found that the results are different in the ordering of the results.

Upon further inspection, I found myself able to replicate the results by surrounding my query with asterisks by reading the code.

May I ask, why were the asterisks there surrounding the query?

Also, when I surrounded the query with asterisks, all the _scores became 1? Isn't that useless in ordering the results?

https://github.com/ErickTamayo/laravel-scout-elastic/blob/master/src/ElasticsearchEngine.php#L134

Importing partially

Hi,

I have a table with more than 100k entries and running scout:import MyModel it's importing only 2210 entries. I'm testing it via http://localhost:9200/laravel/my_index/_count.

Any idea?

I have some smaller tables that it is working fine.

I am facing a problem createDriver() .

ErrorException in Manager.php line 77:
Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in C:\Users\MD.MOSTAFA KAMAL\ela-search\vendor\laravel\framework\src\Illuminate\Support\Manager.php on line 87 and defined

Indexes aren't created on import

OS X / Laravel 5.4
Elasticsearch 5.4 (running, homebrew)
"laravel/scout": "^3.0",
"tamayo/laravel-scout-elastic": "^3.0",
"elasticsearch/elasticsearch": "^5.2",
QUEUE=sync

Importing the model:

php artisan scout:import "Acme\Models\Service"
Imported [Acme\Models\Service] models up to ID: 100
Imported [Acme\Models\Service] models up to ID: 200
Imported [Acme\Models\Service] models up to ID: 300
Imported [Acme\Models\Service] models up to ID: 400
Imported [Acme\Models\Service] models up to ID: 500
Imported [Acme\Models\Service] models up to ID: 530
All [Acme\Models\Service] records have been imported.

Result from http://localhost:9200/_cat/indices?v

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

Tested with all models after multiple ES restarts. Happens every time for every model.

Changing driver creates indexes successfully in MySQL or Solr.

Bulk Indexing huge database

Hey Erick,

I have a database with a fairly amount of entries (30,000+) for one of my models. I have set up queueing for indexing to reduce the initial load. Nonetheless when I try to bulk index the models with the elasticsearch driver the indexing process is nearly brought down to its knees.

I think one part of the problem could be how the ElasticsearchEngine->update() method prepares the data for indexing. In my case the method receives like ~12.000 models at once. While mapping is done in about 1-2 seconds, calling ->flatten(1)->toArray() on the mapped data will take about 3+ minutes.

The other part is that 12,000 models at once is way too much for like every one of the ~300 jobs created for queueing IMO, but that again is clearly not happening on your side. Maybe you have an idea why the amount of models is that high with every job processed? In the end there are like 100 docs created with every job.

If needed, I can create a pull request with a modified handler to process the models in smaller chunks.

Thanx for bringing elasticsearch to the table anyway!

require scout ^1

laravel/scout currently is at v2. composer requires v1. any update? 😄

"require": {
    "laravel/scout": "^1.0",
},

Issues with special characters

Seems like there is an issue with special finnish characters such as ö and ä. For example:

Product::search('kaniininmetsastaja')->get();

Works just fine, but throws the exception / stack trace below.

Product::search('kaniininmetsästäjä')->get();

InvalidArgumentException in CurlFactory.php line 289:
Invalid request body provided
in CurlFactory.php line 289

at CurlFactory->addStreamingBody(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json'))), array('_headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json')), 'GET', 'http://localhost:9200/partner-portal/products/_search', false, false, 150, object(Closure), 3, true)) in CurlFactory.php line 248
at CurlFactory->applyBody(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json'))), array('_headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json')), 'GET', 'http://localhost:9200/partner-portal/products/_search', false, false, 150, object(Closure), 3, true)) in CurlFactory.php line 203
at CurlFactory->applyMethod(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json'))), array('_headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json')), 'GET', 'http://localhost:9200/partner-portal/products/_search', false, false, 150, object(Closure), 3, true)) in CurlFactory.php line 30
at CurlFactory->__invoke(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json'))), resource) in CurlHandler.php line 84
at CurlHandler->_invokeAsArray(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json')))) in CurlHandler.php line 68
at CurlHandler->__invoke(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json')))) in Middleware.php line 30
at Middleware::GuzzleHttp\Ring\Client\{closure}(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json')))) in Connection.php line 196
at Connection->Elasticsearch\Connections\{closure}(array('http_method' => 'GET', 'scheme' => 'http', 'uri' => '/partner-portal/products/_search', 'body' => false, 'headers' => array('host' => array('localhost:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json'))), object(Connection), object(Transport), array()) in Connection.php line 171
at Connection->performRequest('GET', '/partner-portal/products/_search', array(), false, array(), object(Transport)) in Transport.php line 100
at Transport->performRequest('GET', '/partner-portal/products/_search', array(), array('query' => array('bool' => array('must' => array(array('query_string' => array('query' => '*kaniininmets�st�j�*')))))), array()) in Client.php line 1502

Return empty collection if models are not found.

I'm not sure if this is a problem that's working as intended..

However, when searching and the map method on ElasticSearchEngine is called, it only checks the results from elasticsearch..

What if the model was manually deleted from the database?
That would make it unable to find the $hit matching the id and generate a error 500 :)

Problem with Eloquent model _id field

Making a first test with Laravel 5.5 scout (and jensseger/mongodb moloquent as base models), I found none of my documents has been indexed, no matter what I do.

I could track down the problem (covered by #37) to this root cause:
The default eloquent toArray() function returns the id field with leading underscore.
[
"_id" => "59f37e9b8ba21650953e7272",
"name" => "some name",
"description" => "some description",
"updated_at" => "2017-10-27 18:44:43",
"created_at" => "2017-10-27 18:44:43",
]

So, ES throws the following error:
{"_index":"scout","_type":"testmodel","_id":"59f37e9b8ba21650953e7272","status":400,"error":{"type":"mapper_parsing_exception","reason":"Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters."}}}]}

Mapping the _id field to "id" within a custom toSearchableArray() method fixes the problem.

This issue is related exclusively to ES expecting special fields with underscores.
So, within the chain of Eloquent, Scout, your driver and ES it should be fixed here, I think.

Sample Elasticsearch Configuration differs from code

I think the sample configuration shown in readme should be changed to

// config/scout.php
// Set your driver to elasticsearch
    'driver' => env('SCOUT_DRIVER', 'elasticsearch'),

...
    'elasticsearch' => [
        'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
        'config'=>[
            'hosts' => [
                env('ELASTICSEARCH_HOST', 'http://localhost'),
            ]
        ],
    ],
...

The provider is picking us hosts from

config('scout.elasticsearch.config.hosts')

not working with laravel mongodb

I am using Jenssegers laravel mongodb package

https://github.com/jenssegers/laravel-mongodb/

On importing data through model, no mappings are created.
and search also doesnt gives any result
please help

User Model

`

protected $fillable = [
    'name', 'email', 'password',
];
protected $hidden = [
    'password', 'remember_token',
];
protected $dates = [
    'updated_at',
    'created_at'
];

`

scout.php

`

'driver' => env('SCOUT_DRIVER', 'elasticsearch'),

'prefix' => env('SCOUT_PREFIX', ''),

'queue' => false,

'elasticsearch' => [
    'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
    'hosts' => [
        env('ELASTICSEARCH_HOST', 'http://192.168.10.10'),
    ],
],

`

Search Error: Fielddata is disabled on text fields by default.

Hi,
Laravel 5.4, ES 5.2.0.

Importing fine, but on search I get:

(1/1) BadRequest400Exception {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"xxxxxxxxx","node":"GMpAuk7dRzSA0TVfY5EwNA","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}}],"caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}},"status":400}

Any hint?

Thanks.

Error on queue importing (Abstract method)

Hey when i run my queue worker for importing i get the following error:

[Symfony\Component\Debug\Exception\FatalErrorException]
Class ScoutEngines\Elasticsearch\ElasticsearchEngine contains 1 abstract me
thod and must therefore be declared abstract or implement the remaining met
hods (Laravel\Scout\Engines\Engine::getTotalCount)

[BUG] Field in where clause is ambiguous

ElasticsearchEngine.php

Method map
$models = $model->whereIn( $model->getKeyName(), $keys )->get()->keyBy($model->getKeyName());

change getKeyName() to getQualifiedKeyName()

$models = $model->whereIn( $model->getQualifiedKeyName(), $keys )->get()->keyBy($model->getKeyName());

Laravel 5.3 Unresolvable dependency

Dear Erick,

I tried to use your package to an almost clean laravel 5.3 installation on php7.

When i place your ScoutEngines\Elasticsearch\ElasticsearchProvider::class in the providers array i get the following error:
[Illuminate\Contracts\Container\BindingResolutionException] Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager

Do you have any idea what is wrong?

Have a great evening!

Not able to search by number or @ sign

Hi,

Thank you for this package. If i search by just a normal search string, it works fine. However, lets say I have a record containing an emailadress, the search is not returning any results. It is also not working if the search string is numeric.

Thank you.

custom index options?

Hello

if I would like to have custom index, like:

$params = [
            'index' => $this->index,
            'body' => [
                'settings' => [
                    'number_of_shards' => 5,
                    'number_of_replicas' => 1,
                ],
                'mappings' => [
                    $this->type => [
                        'properties' => [
                            'id' => [
                                'type' => 'integer',
                            ],
                            'uri' => [
                                'type' => 'keyword',
                                //'analyzer' => 'standard'
                            ],
                            'name' => [
                                'type' => 'text',
                                'analyzer' => 'standard'
                            ],
                            'about_me' => [
                                'type' => 'text',
                                'analyzer' => 'standard'
                            ],
                            'created_at' => [
                                'type' => 'date',
                                'format' => 'yyyy-MM-dd HH:mm:ss'
                            ],
                        ],
                    ],
                ],
            ],
        ];

Do you have suggestions?

Thank you!

Where Clauses

I get an error when using this code
Post::search($keyword)->where('id', '>', 6)->get();

What's the code for needs like this?

laravel/scout 3.0^ support

When pulling down laravel scout through composer I'll get 3.0 and will causes dependency issues.

Will this be supported? :)

function 'searchable' not throwing when an error occurs in elastic search

In elastic I try to import a invalid date field mapped as such:

    'some_date' => [
        'type' => 'date',
        'include_in_all' => false,
        'format' => 'yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis',
        //'ignore_malformed' => true // this is my temporary fix for now..
    ],

when indexing my model with, for example, the following code:

    // force to not use a queue, directly commit results
    $queueManager->setDefaultDriver('sync');
    User::find(1)->searchable(); // doesn't throw and always returns null

The code doesn't throw an exception nor I can deduce any errors from the return value (which is always NULL) of the searchable() call.

When doing the same in eloquent by doing

PUT /index/users/1
{
    "user" : {
        "id": 1,
        "some_date": "0000-00-00 00:00:00"
    }
}

I get the following response from elastic search:

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "failed to parse [user.some_date]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "failed to parse [user.some_date]",
        "caused_by": {
            "type": "illegal_field_value_exception",
            "reason": "Cannot parse \"0000-00-00 00:00:00\": Value 0 for monthOfYear must be in the range [1,12]"
        }
    },
    "status": 400
}

which is correct, because this should throw an error/exception.

toSearchableArray() does not work

I define the method toSearchableArray() in my model, redefining the array that should be indexed but somehow I always have the default array indexed ($this-toArray()). Can anybody give a clue about this issue? Here is my code:

public function toSearchableArray()
    {
        if($this->folleto->catalogo->Vigente() && !($this->esExcursion()) && $this->PrecioMinimo()){
            
            $my_array = array();
            $my_array['id'] = $this->id;
            $my_array['code'] = $this->folleto->codcomis.'-'.$this->coditine;
            $my_array['price'] = $this->PrecioMinimo();
            $my_array['days'] = sprintf("%02d", $this->numedias);           
            return $my_array;           
        }
        else
            return [];
    }

Doesn't support Eloquent Local Scopes

I can't use local scopes for searching. For example, instead of this:

App\Article::search('An older article')
    ->published()
    ->get();

I must use this:

App\Article::search('An older article')
    ->where('status', 1)
    ->get();

Aggregation Support?

First of all I like your library. Works great for search.

I have a question is there any support voor aggregations?

I would love to use filters and the result counts.

Return all results (not default max of 10)

I have used this package in production and only just noticed that Elastic Search gives me a maximum of 10 results by default.

So if I do
Model::search('text')->get();
I get only 10 results.

Whereas if I do:
Model::search('text')->paginate( (int) $aBigNumber );
I get a maximum of (int) $aBigNumber results.

Is there a way to get all results when I use get()?

use elasticsearch to store relation data

Currently scout support saving custom fields into ES using toSearchableArray, but when getting data from ES, the returned keys are the same with model keys.

So how about return the whole document in ES so we don't need to do manual sql join to get additional data.

AWS Elastic support?

I have looked everywhere for a simple and easy Laravel Scout Elasticsearch library and yours seems to be one of the best but you don't support Aws Elasticsearch with Signature Version 4 Authentication.
I forked your repo and added Aws support and used in my project using the forked repo with composer.
So I just wanted to know if you are willing to adding the support and if so I can send you a pull request?
Will wait for your reply.
Thanks

No alive nodes found in your cluster error

When I run php artisan scout:import App\\Post, I got the error:

local.ERROR: Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster

And I found a mistake in ElasticsearchProvider:

return new ElasticsearchEngine(ElasticBuilder::create()
                ->setHosts(config('scout.elastic.hosts'))
                ->build(),
                config('scout.elasticsearch.index')
            );

there are elastic.hosts and elasticsearch.index in this code. But add

    'elasticsearch' => [
        'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
        'hosts' => [
            env('ELASTICSEARCH_HOST', 'http://localhost/'),
        ],
    ],

in the scout.php file.

I changed scout.elastic.hosts to scout.elasticsearch.hosts but still get that error.

Pagination doesn't seem to work

I've indexed some 700k records and checked in elasticHQ what the query *tux*, that returns 114 records, same happens if I paginate a number higher than the expected numbers. but when I do

$players = User::search('tux')->paginate(24);

I get 24 results and an empty paginator.

Odd issue with import

I'm using scout:import to push my data into local ES (OSX). All good.

When I try to use import on ubuntu 16.04 (forge) wi ES 5.2.2 nothing happens.
It says the import was successful, no log errors, nothing, but data isn't there.

I can send data using curl, only the import doesn't work.

Thank you for any help you could provide

ElasticsearchEngine doesn't care about Builder::$index

ElasticsearchEngine uses $this->index instead of $builder->index, which makes it impossible to search in different indices. It looks like $builder->index is null if you don't set it to something using the within-function, so you could probably just use this:

'index' => $builder->index ?: $this->index,

Test with searchable models fails

It seems that in my tests indexing the created items isn't completed when I start searching for them. Does indexing happen asynchronously? How can I change this? My queue is already set to sync and SCOUT_QUEUE is set to false.

Here is an example of a test that keeps failing (Failed asserting that search results contain the given post).

Or isn't this an issue at all and would asserting the model's toSearchableArray suffice?

Any help is greatly appreciated.

<?php

namespace Tests\Unit;

use App\Models\Category;
use App\Models\Post;
use App\Models\User;
use Tests\TestCase;

class SearchTest extends TestCase
{
    /** @test * */
    public function it_searches_the_whole_category_tree_for_posts()
    {
        // Given
        /** @var Category $parentCategory */
        $parentCategory = \factory(Category::class)->create([
            'title' => 'myParentCategory',
        ]);
        /** @var Category $childCategory */
        $childCategory = \factory(Category::class)->create();
        $childCategory->makeChildOf($parentCategory);
        /** @var Post $post */
        $post = \factory(Post::class)->create([
            'user_id' => \factory(User::class)->create()->id,
        ]);
        $post->requestCategories()->attach($childCategory);

        // When
        $searchResults = Post::search('myParentCategory')->get();

        // Then
        $this->assertTrue($searchResults->contains($post), 'Failed asserting that search results contain the given post.');
    }
}

Sort Support

why is there no support for sorting!. Elasticsearch does have sorting available. am i missing something here?

Illuminate\Contracts\Container\BindingResolutionException

I'm getting this error message after I add the provider to app.php:

[Illuminate\Contracts\Container\BindingResolutionException]
  Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager

on a fresh installation of Laravel 5.3.

Implement orderBy

The orderBy method does not work with this driver.

It seems to have been addressed in #40, will this be landed any time soon?

Failed to parse query containing curly braces {}

When performing a search for a query that has curly braces I get the exception thrown below.

I came across this which states that certain characters need to be escaped before searching http://stackoverflow.com/questions/40384936/elasticsearch-query-string-fails-to-parse-query-with-some-characters

Can the escaping be doing by the scout package or should it be done as required by the developer?

{
   "error":{
      "root_cause":[
         {
            "type":"query_shard_exception",
            "reason":"Failed to parse query [*{search_term_string}*]",
            "index_uuid":"OpsZUbZnS-OOMOOgoObecQ",
            "index":"gindex"
         }
      ],
      "type":"search_phase_execution_exception",
      "reason":"all shards failed",
      "phase":"query",
      "grouped":true,
      "failed_shards":[
         {
            "shard":0,
            "index":"gindex",
            "node":"sBY7rEmfTXmxbcCbhyIseQ",
            "reason":{
               "type":"query_shard_exception",
               "reason":"Failed to parse query [*{search_term_string}*]",
               "index_uuid":"OpsZUbZnS-OOMOOgoObecQ",
               "index":"gindex",
               "caused_by":{
                  "type":"parse_exception",
                  "reason":"Cannot parse '*{search_term_string}*': Encountered \" \"}\" \"} \"\" at line 1, column 20.\nWas expecting one of:\n \"TO\" ...\n <RANGE_QUOTED> ...\n <RANGE_GOOP> ...\n ",
                  "caused_by":{
                     "type":"parse_exception",
                     "reason":"Encountered \" \"}\" \"} \"\" at line 1, column 20.\nWas expecting one of:\n \"TO\" ...\n <RANGE_QUOTED> ...\n <RANGE_GOOP> ...\n "
                  }
               }
            }
         }
      ],
      "caused_by":{
         "type":"query_shard_exception",
         "reason":"Failed to parse query [*{search_term_string}*]",
         "index_uuid":"OpsZUbZnS-OOMOOgoObecQ",
         "index":"gindex",
         "caused_by":{
            "type":"parse_exception",
            "reason":"Cannot parse '*{search_term_string}*': Encountered \" \"}\" \"} \"\" at line 1, column 20.\nWas expecting one of:\n \"TO\" ...\n <RANGE_QUOTED> ...\n <RANGE_GOOP> ...\n ",
            "caused_by":{
               "type":"parse_exception",
               "reason":"Encountered \" \"}\" \"} \"\" at line 1, column 20.\nWas expecting one of:\n \"TO\" ...\n <RANGE_QUOTED> ...\n <RANGE_GOOP> ...\n "
            }
         }
      }
   },
   "status":400
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.