Я относительно новичок вasticsearch и пытаюсь выполнить поиск по приведенному ниже запросу в php, но получаю ошибку.
$query = array(
'query' => array(
'query_string' => array(
'query' => "(name_en:cook)^2 OR (name_en:door) AND (_id:11)",
)
),
'suggest' => array(
'text' => "unganda",
'term'=>array(
"field"=> "name_en",
"max_edits"=> 2,
"sort"=> "score",
"suggest_mode"=>"missing",
"prefix_length"=> 0,
"min_word_length"=> 2
)
)
);
$response = $client->request($path, \Elastica\Request::GET, $query);
$responseArray = $response->getData();
// Loop through the results
return $responseArray;
diE();
Это правильный способ сделать это. Может кто-нибудь сказать мне, как написать это. Я следую этот пример.
Вот вся ошибка:
( ! ) Fatal error: Uncaught exception 'Elastica\Exception\ResponseException' with message
'SearchPhaseExecutionException[Failed to execute phase [query], all shards failed;
shardFailures {[NBYNTLSbT1iIRv98Oxvbmw][shops][3]:
SearchParseException[[shops][3]:
query[(
(_all:name_en _all:uganda)^2.0)
(_all:name_en _all:grocery_shop)],from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query":"(name_en=>uganda)^2 OR (name_en=>grocery_shop)"}
},
"suggest": {
"text": "grocery_shop",
"term": {
"field": "name_en"}
}
}]]];
nested: ElasticsearchIllegalArgumentException[[suggest] does not support [field]]; }{[NBYNTLSbT1iIRv98Oxvbmw][shops][4]:
SearchParseException[[shops][4]:
query[(
(_all:name_en _all:uganda)^2.0)
(_all:name_en _all:grocery_shop)],from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query":"(name_en=>uganda)^2 OR (name_en=>grocery_shop)"}
},
"suggest": {
"text": "grocery_shop",
"term": {
"field": "name_en"}
}
}]]];
nested: Elasticsea in C:\wamp\www\infomoby\vendor\ruflin\elastica\lib\Elastica\Transport\Http.php on line 146
( ! ) Elastica\Exception\ResponseException:
SearchPhaseExecutionException[Failed to execute phase [query], all shards failed;
shardFailures {[NBYNTLSbT1iIRv98Oxvbmw][shops][3]:
SearchParseException[[shops][3]:
query[(
(_all:name_en _all:uganda)^2.0)
(_all:name_en _all:grocery_shop)],from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query":"(name_en=>uganda)^2 OR (name_en=>grocery_shop)"}
},
"suggest": {
"text": "grocery_shop",
"term": {
"field": "name_en"}
}
}]]];
nested: ElasticsearchIllegalArgumentException[[suggest] does not support [field]]; }{[NBYNTLSbT1iIRv98Oxvbmw][shops][4]:
SearchParseException[[shops][4]:
query[(
(_all:name_en _all:uganda)^2.0)
(_all:name_en _all:grocery_shop)],from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query":"(name_en=>uganda)^2 OR (name_en=>grocery_shop)"}
},
"suggest": {
"text": "grocery_shop",
"term": {
"field": "name_en"}
}
}]]];
nested: ElasticsearchIllegalArgumentException[[suggest] does not support [field]]; }{[NBYNTLSbT1iIRv98Oxvbmw][shops][1]:
SearchParseException[[shops][1]:
query[(
(_all:name_en _all:uganda)^2.0)
(_all:name_en _all:grocery_shop)],from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query":"(name_en=>uganda)^2 OR (name_en=>grocery_shop)"}
},
"suggest": {
"text": "grocery_shop",
"term": {
"field": "name_en"}
}
}]]];
nested: ElasticsearchIllegalArgumentException[[suggest] does not support [field]]; }{[NBYNTLSbT1iIRv98Oxvbmw][shops][2]:
SearchParseException[[shops][2]:
query[(
(_all:name_en _all:uganda)^2.0)
(_all:name_en _all:grocery_shop)],from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query":"(name_en=>uganda)^2 OR (name_en=>grocery_shop)"}
},
"suggest": {
"text": "grocery_shop",
"term": {
"field": "name_en"}
}
}]]];
nested: ElasticsearchIllegalArgumentException[[suggest] does not support [field]]; }{[NBYNTLSbT1iIRv98Oxvbmw][shops][0]:
SearchParseException[[shops][0]:
query[(
(_all:name_en _all:uganda)^2.0)
(_all:name_en _all:grocery_shop)],from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query":"(name_en=>uganda)^2 OR (name_en=>grocery_shop)"}
},
"suggest": {
"text": "grocery_shop",
"term": {
"field": "name_en"}
}
}]]];
nested: ElasticsearchIllegalArgumentException[[suggest] does not support [field]]; }] in C:\wamp\www\shops_site\vendor\ruflin\elastica\lib\Elastica\Transport\Http.php on line 146
В конце концов я вернулся к использованию запросов на основе curl с php, и это сработало как шарм. Секрет в пользовательском фильтре bool с опцией must и must, позволяющей вкладывать нечеткие данные и сопоставлять запросы
Других решений пока нет …