elasticsearch中的相同类型的相关性 [英] Relevance by type on same field in elasticsearch
问题描述
是否有任何方法可以根据类型在同一个字段上添加 boost
搜索结果?
我的基本提示是例如:
GET _search
{
query:{
simple_query_string :{
query:mangan,
fields:[_ all,title ^ 6]
}
}
}
但是对于其他一些文档,我希望title不那么重要,所以我试着用类型前缀:
GET _search
{
query:{
simple_query_string:{
query:mangan,
fields:[
_all,
DocumentationPage.title ^ 6,
DocumentationPage.title ^ 6 ]
}
}
}
但它不会提升。作为最后的手段,我可以使用 为了举例,假设文档只包含 实现这一点的一种简单方法是重写查询在OP中作为 dis -max查询。 elasticsearch 5.x示例: Is there any way to My basic boosting is something like: But for some other documents I want title to be less important, so I tried to prefix it with type: But then it does not boost at all. As a last resort I could use Funcsion/Script Score bu would like to avoid it. For sake of example, assume that document contains just A simple way to achieve this is re-writing the query in the OP as a dis-max query. Example for elasticsearch 5.x:
这篇关于elasticsearch中的相同类型的相关性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
title
字段。
query:{
dis_max:{
queries:[
{
simple_query_string:{
fields:[
_all
],
query:mangan
}
},
{
bool:{
filter:{
type:{
value:DocumentationPage
}
},
必须:[
{
simple_query_string:{
fields:[
title ^ 6
,
query:mangan
}
}
]
}
}
]
}
}
}
boost
search results on same field depending on type?GET _search
{
"query": {
"simple_query_string": {
"query": "mangan",
"fields":["_all", "title^6"]
}
}
}
GET _search
{
"query": {
"simple_query_string": {
"query": "mangan",
"fields":[
"_all",
"DocumentationPage.title^6",
"DocumentationPage.title^6"]
}
}
}
title
field. {
"query": {
"dis_max": {
"queries": [
{
"simple_query_string": {
"fields": [
"_all"
],
"query": "mangan"
}
},
{
"bool": {
"filter": {
"type": {
"value": "DocumentationPage"
}
},
"must": [
{
"simple_query_string": {
"fields": [
"title^6"
],
"query": "mangan"
}
}
]
}
}
]
}
}
}