所以我试图找到“name”字段中包含“ssh”的所有文档,其中字段“versions”等于12.1.2,12.1.1,... 这是我的参数:
$params = [
'index' => 'notes',
'type' => 'release',
'body' => [
'query' => [
'bool' => [
'must' => [
'match' => [ 'name' => 'ssh' ]
],
'filter' => [
'term' => [ 'versions' => '12.1.2, 12.1.1, 12.1.0' ]
]
]
]
]
];
这是一个示例文档:
Array
(
[_index] => notes
[_type] => release
[_id] => AVo3jnT2RJ1Gn1RjrM7p
[_score] => 0.52541894
[_source] => Array
(
[name] => 621423 : sys-icheck reports error with /config/ssh/ssh_host_dsa_key
[component] => TMOS
[symptoms] => On Azure cloud, running sys-icheck may report an error with /config/ssh/ssh_host_dsa_key and other files: ERROR: missing /config/ssh/ssh_host_dsa_key ERROR: missing /config/ssh/ssh_host_dsa_key.pub ERROR: missing /config/ssh/ssh_host_key ERROR: missing /config/ssh/ssh_host_key.pub
[conditions] => This occurs on BIG-IP running on Azure cloud.
[impact] => sys-icheck utility indicates an error. The sys-icheck utility is used to find file system changes that have occurred since initial installation and provide information about their status.
[workaround] =>
[fix] => Fixed an issue with files in /config/ssh/ that was causing sys-icheck to report errors.
[versions] => 12.1.2, 12.1.1, 12.1.0
)
)
根据要求,这是name
映射:
{
notes: {
mappings: {
release: {
name: {
full_name: "name"
mapping: {
name: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
} -
} -
} -
} -
} -
}
来自/ GET / notes的结果:
{
notes: {
aliases: {}
mappings: {
release: {
properties: {
component: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
conditions: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
fix: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
impact: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
name: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
symptoms: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
versions: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
workaround: {
type: "text"
fields: {
keyword: {
type: "keyword"
ignore_above: 256
} -
} -
} -
} -
} -
} -
settings: {
index: {
creation_date: "1486999820715"
number_of_shards: "5"
number_of_replicas: "1"
uuid: "SZfFCZ-HRT6Yr17epsv2-Q"
version: {
created: "5020099"
} -
provided_name: "notes"
} -
} -
} -
}
过滤器是唯一的工作语句,因为我得到了所有12.1.2文档。有什么想法吗?
答案 0 :(得分:0)
因为analyzer
字段name
设置为keyword
。执行此操作时,它不会标记关键字。因此,您必须使用整个文本来搜索该文档。
如果您在must
中使用以下内容,则意味着它会为您提供输出。
621423 : sys-icheck reports error with /config/ssh/ssh_host_dsa_key
查看keyword anlyzer
here
答案 1 :(得分:0)
以下查询适用于我,即您需要对terms
使用versions
查询,并且每个版本都有一个数组。
$params = [
'index' => 'notes',
'type' => 'release',
'body' => [
'query' => [
'bool' => [
'must' => [
'match' => [ 'name' => 'ssh' ]
],
'filter' => [
'terms' => [
'versions' => ['12.1.2', '12.1.1', '12.1.0']
]
]
]
]
]
];