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

Searching dates #5

Open
minicstudio opened this issue Aug 4, 2014 · 3 comments
Open

Searching dates #5

minicstudio opened this issue Aug 4, 2014 · 3 comments

Comments

@minicstudio
Copy link

Hi,

This is a question regarding ranges so mark it please.

My question is that is there support for date search? I`m building a portal and i need to implement ranged search with dates, for example i need to search the posts which were published in the past month.

Thanks!

@mmanos
Copy link
Owner

mmanos commented Aug 4, 2014

Range searches are not yet supported. But it seems like an excellent feature for the next version.

In the meantime, you could try using an Advanced Query Callback to modify the query before it gets sent.

@minicstudio
Copy link
Author

Can you provide any example? I dont know how could i do it.

@dmyers
Copy link
Collaborator

dmyers commented May 22, 2016

Yeah it's bit complicated to use the advanced query callback and requires you to really dive into the package and understand the internals. Essentially you can get access to the driver's client and then use exposed methods to do advanced queries, but you will be tied to that driver for that implementation.

Here's the example from the readme. See how it is altering the $query array? That array is passed to the driver, in this case Elastic Search.

$results = Search::index('posts')->select('id', 'created_at')
    ->search('content', 'fox')
    ->addCallback(function ($query) {
        // Adjust pagination for an elasticsearch query array.
        $query['from'] = 0;
        $query['size'] = 20;
        return $query;
    }, 'elasticsearch')
    ->get();

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

2 participants