如何使用 elasticsearch php 允许部分字符串搜索

How to allow partial string searches with elasticsearch php

我正在尝试让 elasticsearch 允许我使用 php client library.

搜索部分字符串

我有这样的脚本

// create an index
$params = array();
$params['body']  = array('testField' => 'abc');
$params['index'] = 'my_index';
$params['type']  = 'my_type';
$params['id']    = 'my_id';
$ret = $client->index($params);

// search for that index
$searchParams['index'] = 'my_index';
$searchParams['type']  = 'my_type';
$searchParams['body']['query']['match']['testField'] = 'abc';
$queryResponse = $client->search($searchParams); // contains the indexed `abc` testField

这有效,我能够找到我刚刚创建的东西。

然而,当我替换

$searchParams['body']['query']['match']['testField'] = 'abc';

$searchParams['body']['query']['match']['testField'] = 'a';

$searchParams['body']['query']['match']['testField'] = 'a*';

搜索 returns 零个结果。

是否需要设置某些配置以允许部分字符串搜索?

我在解决我提出的一个单独的 Whosebug 问题时解决了这个问题 。工作脚本在那里。

感谢@sloan-ahrens 给我指导