cakephp / elastic-search

Elastic search datasource for CakePHP
Other
88 stars 53 forks source link

Where don't work. #131

Closed mvdornellas closed 7 years ago

mvdornellas commented 7 years ago

Hello guys, Someone can help me? i have an mapping call doacoes and i did a query with a basic condition with "where" but i receive a wrong response "Wrong parameters for Elastica\Exception\ResponseException([string $message [, long $code [, Throwable $previous = NULL]]])". I only get wrong message when i use condition "where", however, when i use $doacao = $this->Doacoes->find(), it works perfectly.

With condition "WHERE"!

captura de tela 2017-08-20 as 17 24 11 captura de tela 2017-08-20 as 17 29 20

Without condition "WHERE"!

captura de tela 2017-08-20 as 17 24 27 captura de tela 2017-08-20 as 17 24 37
lorenzo commented 7 years ago

What version of this plugin are you using? and what version of elastic search?

If you use Elastic search >= 2.0, then you need to use the 1.0 branch of this plugin

mvdornellas commented 7 years ago

Hi @lorenzo so im working with this plugin in version "dev-master" and elasticsearch 5.5, apparently it's all right, Would you have another option?

lorenzo commented 7 years ago

Try "cakephp/elastic-search": "1.*" in your composer.json

mvdornellas commented 7 years ago

It Worked, thank you @lorenzo. However, im try make an query with clause "LIKE" and it is not working, you can do an example of query using "LIKE" please?

lorenzo commented 7 years ago

@dornellas13 you will have to read the elastic documentation, there are many valid answers to your question, each of them with different characteristics.

You could start with


$query->where(function ($builder) {
    return $builder->simpleQueryString('my_field', 'search this');
})`
mvdornellas commented 7 years ago

Thank you @lorenzo.