How to Use Full Text Search Properly on PHP SDK

Hi, please help me how to full text search on php sdk, I’m using laravel for this but seems not working at all, heres my code snippet for search query

       $query = "SELECT * FROM `Bucket` WHERE SEARCH(`json_data`, {'query': '123'})";
        $response = $this->cluster->query($query)->rows();

But it gives me an error message of:

"internal_server_failure (5): \"unable to execute HTTP operation \"query\": ec=5 (internal_server_failure)\", serverError=5000, \"n1fty: search failed - cause: rpc error: code = Canceled desc = grpc: the client connection is closing\" in 'http_execute'

Please guide me how to use it properly, I am using PHP SDK version 4 for this, thanks.

@gelopi_ghost I see that you’re using the query service to perform a SEARCH operation, but the first thing I wanted to point out is that you can perform a full text search using the FTS service and searchQuery as instructed in the PHP documentation and the server documentation for Search.

You can see an example of this style of search in our sample app in the HotelController.php file.

If you do still want to execute this statement as a N1QL query then you should review the documentation for the N1QL SEARCH function, and pay attention to the prerequisites section and authorization requirements. In particular, verify that the Search Service is enabled and available, indexes are created, and permissions are granted.

You can see an example of a query (but it’s not a SEARCH query) in our sample app in the AirportController.php file.

okay @raycardillo I will try to follow this HotelController.php and will update you soon. Thanks.

1 Like