如何使用php api分析字符串
如何使用PHP API使用此函数。我没有找到解决这个问题的方法如何使用php api分析字符串,php,elasticsearch,query-string,analyzer,Php,elasticsearch,Query String,Analyzer,如何使用PHP API使用此函数。我没有找到解决这个问题的方法 curl -XGET 'localhost:9200/_analyze?analyzer=standard' -d 'this is a test' 我需要访问它,因为我需要访问通过script\u score计算我的分数的查询字符串。当然,不会分析查询字符串。所以我必须分开做 我知道这不是一个好的解决方案,但我直到现在才找到替代方案。它位于索引名称空间中: /** * $params['index'] = (string) T
curl -XGET 'localhost:9200/_analyze?analyzer=standard' -d 'this is a test'
我需要访问它,因为我需要访问通过script\u score计算我的分数的查询字符串。当然,不会分析查询字符串。所以我必须分开做
我知道这不是一个好的解决方案,但我直到现在才找到替代方案。它位于索引名称空间中:
/**
* $params['index'] = (string) The name of the index to scope the operation
* ['analyzer'] = (string) The name of the analyzer to use
* ['field'] = (string) Use the analyzer configured for this field (instead of passing the analyzer name)
* ['filters'] = (list) A comma-separated list of filters to use for the analysis
* ['prefer_local'] = (boolean) With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)
* ['text'] = (string) The text on which the analysis should be performed (when request body is not used)
* ['tokenizer'] = (string) The name of the tokenizer to use for the analysis
* ['format'] = (enum) Format of the output
* ['body'] = (enum) Format of the output
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function analyze($params = array())
{
$index = $this->extractArgument($params, 'index');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->dicEndpoints;
/** @var \Elasticsearch\Endpoints\Indices\Analyze $endpoint */
$endpoint = $endpointBuilder('Indices\Analyze');
$endpoint->setIndex($index)
->setBody($body);
$endpoint->setParams($params);
$response = $endpoint->performRequest();
return $response['data'];
}
它位于索引名称空间中:
/**
* $params['index'] = (string) The name of the index to scope the operation
* ['analyzer'] = (string) The name of the analyzer to use
* ['field'] = (string) Use the analyzer configured for this field (instead of passing the analyzer name)
* ['filters'] = (list) A comma-separated list of filters to use for the analysis
* ['prefer_local'] = (boolean) With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)
* ['text'] = (string) The text on which the analysis should be performed (when request body is not used)
* ['tokenizer'] = (string) The name of the tokenizer to use for the analysis
* ['format'] = (enum) Format of the output
* ['body'] = (enum) Format of the output
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function analyze($params = array())
{
$index = $this->extractArgument($params, 'index');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->dicEndpoints;
/** @var \Elasticsearch\Endpoints\Indices\Analyze $endpoint */
$endpoint = $endpointBuilder('Indices\Analyze');
$endpoint->setIndex($index)
->setBody($body);
$endpoint->setParams($params);
$response = $endpoint->performRequest();
return $response['data'];
}