【发布时间】:2016-06-10 20:29:12
【问题描述】:
我一直在搜索弹性搜索文档以进行搜索,但不幸的是我无法理解如何按主题学习弹性搜索主题。
在这里,我想在 my_deezer 索引中搜索所有艺术家 = "blah" 且年份 = 2004 的歌曲。
当我提供多个字段进行匹配时,我正在使用 PHP 客户端及其返回错误。
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->build();
$params = [
'index' => 'my_deezer',
'type' => 'song',
'body' => [
'query' => [
'match' => [
'artist' => 'blah',
'year' => 2004
]
]
]
];
try {
$response = $client->search($params);
print_r($response);
} catch (Exception $e) {
echo $e->getMessage();
}
另外,我正在寻找一些链接,以了解如何执行不同的查询操作,例如搜索字段 x 大于/小于/不等于某个值的位置。
谢谢
// 错误
SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[hIY53G4ySJm0xQz0Lpqjxg][my_deezer][0]: SearchParseException[[my_deezer][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"artist":"jal","year":2001}}}]]]; nested: QueryParsingException[[my_deezer] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[hIY53G4ySJm0xQz0Lpqjxg][my_deezer][1]: SearchParseException[[my_deezer][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"artist":"jal","year":2001}}}]]]; nested: QueryParsingException[[my_deezer] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[hIY53G4ySJm0xQz0Lpqjxg][my_deezer][2]: SearchParseException[[my_deezer][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"artist":"jal","year":2001}}}]]]; nested: QueryParsingException[[my_deezer] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[hIY53G4ySJm0xQz0Lpqjxg][my_deezer][3]: SearchParseException[[my_deezer][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"artist":"jal","year":2001}}}]]]; nested: QueryParsingException[[my_deezer] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[hIY53G4ySJm0xQz0Lpqjxg][my_deezer][4]: SearchParseException[[my_deezer][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"artist":"jal","year":2001}}}]]]; nested: QueryParsingException[[my_deezer] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }]
【问题讨论】:
-
返回什么错误?
-
有问题更新
-
尝试添加
'query' => [ 'must' => [ 'match => [...注意'must' => [ -
对于大于/小于尝试
'query' => [ 'must' => [ [ 'range' => [ 'year' => [ 'gte' => 2001 ] ] ] ] ],其中gte表示大于/等于并用lte替换小于/等于
标签: php elasticsearch