Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggest is not working #103

Open
fuess opened this issue Aug 5, 2015 · 0 comments
Open

suggest is not working #103

fuess opened this issue Aug 5, 2015 · 0 comments

Comments

@fuess
Copy link

fuess commented Aug 5, 2015

Hi! I have two Eloquent models Eventdate and Event:

class EventDate {

    use SearchableTrait;

    public static $__es_config = [
        'suggest'       => ['event.name', 'event.excerpt', 'event.description']
    ];


    public function event()
    {
        return $this->belongsTo(Event::class);
    }


class Event {
    use CallableTrait;

    public function dates()
    {
        return $this->hasMany(EventDate::class);
    }

I run the index process with:
php artisan larasearch:paths --relations --write-config Namespace\EventDate
php artisan larasearch:reindex --relations Namespace\EventDate

The index is created and I can succesfully do simple (exact match) searches. But I can't get suggestions to work, although I have them set up in the $__es_config property.

The response always gives me an empty options array:

{
    "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
    },
    "my-suggestion": [{
        "text": "search_term_with_typo",
        "offset": 0,
        "length": 16,
        "options": []
    }]
}

I use the elasticsearch/elasticsearch package to query the index:

$getMappingParams['index'] = 'event_dates_20150804140349';
$client->indices()->getMapping($getMappingParams);

This gives me a huge array, but the (maybe) relevant parts looks like this:

[event_dates_20150804140349] => Array
    [mappings] => Array
        [_default_]  => Array

            ...dynamic templates...

            [properties] => Array
                (
                    [event] => Array
                        (
                            [properties] => Array
                                (
                                    [description] => Array
                                        (
                                            [type] => string
                                            [index] => not_analyzed
                                            [fields] => Array
                                                (
                                                    [analyzed] => Array
                                                        (
                                                            [type] => string
                                                        )

                                                    [suggest] => Array
                                                        (
                                                            [type] => string
                                                            [analyzer] => larasearch_suggest_index
                                                        )

                                                )

                                        )
                                )
                        )
                )


        [event_date] => Array
            (
                [properties] => Array
                    (
                        [event] => Array
                            (
                                [properties] => Array
                                    (
                                        [description] => Array
                                            (
                                                [type] => string
                                                [index] => not_analyzed
                                                [fields] => Array
                                                    (
                                                        [analyzed] => Array
                                                            (
                                                                [type] => string
                                                             )
                                                        [suggest] => Array
                                                        (
                                                            [type] => string
                                                            [analyzer] => larasearch_suggest_index
                                                         )
                                                    )
                                            )
                                    )
                            )
                    )
            )
    )
)

In the bottom part you can see that [index] is not_analyzed. Shouldn't that be analyzed? Although the [fields] do have an analyzed array and suggest array. Don't know if I'm searching in the right direction? Is the mapping incorrect?

Can someone help with this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant