matchish / laravel-scout-elasticsearch

Search among multiple models with ElasticSearch and Laravel Scout
MIT License
711 stars 115 forks source link

i am trying to search with multiple query but i got error #189

Closed bilginnet closed 2 years ago

bilginnet commented 2 years ago

this is my code..

        $contents = Content::search(
            $request->q,
            function ($algolia) use ($request) {

               // first query
                $options["body"]["query"]["match_phrase_prefix"]["title"]["query"] = "".$request->q."";

              // second query
                $options["body"]["query"]["bool"]["status"]["query"] = "1";

                return $algolia->search($options);
            }
        );

it is working when i run the first query only. But when i try to run with multiple query i got this error:

{"error":{"root_cause":[{"type":"parsing_exception","reason":"[match_phrase_prefix] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":64}],"type":"parsing_exception","reason":"[match_phrase_prefix] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":64},"status":400}

matchish commented 2 years ago

What is the plain query that you are trying to run? Have you tried to run it against elasticsearch using some gui tool? Looks like it's not the package issue, but wrong built query

bilginnet commented 2 years ago

My query should be like this:

where title LIKE "%$query%" and status="1"

matchish commented 2 years ago

I mean full plain query

bilginnet commented 2 years ago

select * from contents where title LIKE "%$query%" and status="1" i dont know how it can be if you asking about elasticsearch query..

matchish commented 2 years ago

Yes I'm asking about plain elasticsearch query