mercredi 31 août 2016

Exclude white space from Elasticsearch when searching

I've got elastic search working great on my site, I can search pretty descent. My problem is when i do a search on something like HipHop vs Hip Hop, or cellphone vs cell phone, my results for the first text query won't appear . I want to make it so that if a user searches either word with or without a space, the results will be the same. here's what my code to search looks like. I'm using Laravel 5

 $q = $request->input('q');
  $response = $client->search([
        'index' => 'users',
        'type' => 'user',
        'body' => [
            'query' => [
                'bool' => [
                    'should' => [
                        ['match' => [ 'text' => $q ] ],
                    ],
                ],  
            ],
        ],
    ]);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire