[英]I am new to ES and have a multi-match query in ES, and want to consider field based on its availability
{
"multi_match": {
"query": "TEST",
"fields": [
"description.regexkeyword^1.0",
"logical_name.regexkeyword^1.0",
"logical_table_name.regexkeyword^1.0",
"physical_name.regexkeyword^1.0",
"presentation_name.regexkeyword^1.0",
"table_name.regexkeyword^1.0"
],
"type": "best_fields",
"operator": "AND",
"slop": 0,
"prefix_length": 0,
"max_expansions": 50,
"lenient": false,
"zero_terms_query": "NONE",
"boost": 1
}
}
There is a field, ie edited_description
, if in case edited_description exists
in document then consider edited_description.regexkeyword^1.0
else consider description, ie description.regexkeyword^1.0
.有一个字段,即
edited_description
,如果edited_description exists
于文档中,则考虑edited_description.regexkeyword^1.0
,否则考虑描述,即description.regexkeyword^1.0
。
You can't define an if condition in multi_match query.您不能在 multi_match 查询中定义 if 条件。 But what you can do is re-look your problem statement in a different way.
但是你能做的是以不同的方式重新审视你的问题陈述。 I can re-look this as, that if in case
edited_description
and description
both exists then the match in edited_description
field should be given a higher preference.我可以重新看待这个,如果
edited_description
和description
都存在,那么edited_description
字段中的匹配应该被给予更高的偏好。
This can achieved by setting slightly higher boost value for edited_description
field.这可以通过为
edited_description
字段设置稍高的提升值来实现。
{
"multi_match": {
"query": "TEST",
"fields": [
"description.regexkeyword^1.0",
"edited_description.regexkeyword^1.2",
"logical_name.regexkeyword^1.0",
"logical_table_name.regexkeyword^1.0",
"physical_name.regexkeyword^1.0",
"presentation_name.regexkeyword^1.0",
"table_name.regexkeyword^1.0"
],
"type": "best_fields",
"operator": "AND",
"slop": 0,
"prefix_length": 0,
"max_expansions": 50,
"lenient": false,
"zero_terms_query": "NONE",
"boost": 1
}
}
This will result in documents having a match in edited_description
to be ranked higher.这将导致在
edited_description
中匹配的文档排名更高。 You can adjust the boosting value to your needs.您可以根据需要调整提升值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.