elasticsearch Elasticsearch 5:Boost 1字段
在Elasticsearch 5中,我有3种类型的字段名称相同: A型elasticsearch Elasticsearch 5:Boost 1字段,elasticsearch,boost,elasticsearch,Boost,在Elasticsearch 5中,我有3种类型的字段名称相同: A型 整数id 字符串名 GET myindex/TypeA,TypeB,TypeC/_search { "_source": ["id", "name"], "query": { "bool": { "should": [ { "query_string": { "fields": [ "_all",
- 整数id
- 字符串名
GET myindex/TypeA,TypeB,TypeC/_search
{
"_source": ["id", "name"],
"query": {
"bool": {
"should": [
{
"query_string": {
"fields": [
"_all",
"name^3"
],
"query": "Foo bar*",
"default_operator": "and"
}
}
]
}
}
}
B型
- 整数id
- 字符串名
GET myindex/TypeA,TypeB,TypeC/_search
{
"_source": ["id", "name"],
"query": {
"bool": {
"should": [
{
"query_string": {
"fields": [
"_all",
"name^3"
],
"query": "Foo bar*",
"default_operator": "and"
}
}
]
}
}
}
C型
-整数id
-字符串名
GET myindex/TypeA,TypeB,TypeC/_search
{
"_source": ["id", "name"],
"query": {
"bool": {
"should": [
{
"query_string": {
"fields": [
"_all",
"name^3"
],
"query": "Foo bar*",
"default_operator": "and"
}
}
]
}
}
}
我只想增加TypeA的name字段。在这个场景中,TypeA、TypeB和TypeC的name字段被提升
我怎样才能只增加TypeA的名称
我在找这样的东西:
"fields": [
"_all",
"TypeA.name^3"
]
谢谢。您需要为类型A创建一个子查询,为类型B和C创建另一个子查询
GET myindex/_search
{
"_source": [
"id",
"name"
],
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"_type": "TypeA"
}
},
{
"query_string": {
"fields": [
"_all",
"name^3"
],
"query": "Foo baar*",
"default_operator": "and"
}
}
]
}
},
{
"bool": {
"must": [
{
"terms": {
"_type": [
"TypeB",
"TypeC"
]
}
},
{
"query_string": {
"fields": [
"_all",
"name"
],
"query": "Foo baar*",
"default_operator": "and"
}
}
]
}
}
]
}
}
}
正是我需要的。谢谢!很高兴它有帮助!