使用query_string时,我有提高搜索速度的问题。我想像上面那样以2秒的速度运行查询,但是现在搜索的费用大约是10秒或以上。 我的问题是query_string中有很多字段,关键字有点难。像这样
{
"from": 0,
"size": "20",
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
[
{
"bool": {
"must": [
[
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "富士",
"type": "phrase_prefix"
}
},
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "エタノール",
"type": "phrase_prefix"
}
},
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "特級",
"type": "phrase_prefix"
}
},
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "500ml",
"type": "phrase_prefix"
}
}
]
]
}
},
{
"bool": {
"must": [
[
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "富士",
"type": "phrase_prefix"
}
},
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "エチルアルコール",
"type": "phrase_prefix"
}
},
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "特級",
"type": "phrase_prefix"
}
},
{
"multi_match": {
"fields": [
"name",
"name_jp",
"volume_unit_label",
"class_name_jp",
"maker_name",
"cas_code",
"supplier_sku",
"ean",
"sales_origin_maker_name"
],
"query": "500ml",
"type": "phrase_prefix"
}
}
]
]
}
},
[
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "*12343 987*"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "富士 エタノール 特級 500ml"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "*富士 エタノール 特級 500ml*"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "富士 エタノール 特級 500ml"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "*富士 エタノール 特級 500ml*"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "富士 エタノール 特級 500ml"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "*富士 エチルアルコール 特級 500ml*"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "富士 エチルアルコール 特級 500ml"
}
}
}
},
{
"bool": {
"must": {
"query_string": {
"fields": [
"name.keyword",
"name_jp.keyword",
"volume_unit_label.keyword",
"class_name_jp.keyword",
"maker_name.keyword",
"cas_code.keyword",
"supplier_sku.keyword",
"ean.keyword",
"sales_origin_maker_name.keyword"
],
"query": "富士 エチルアルコール 特級 500ml"
}
}
}
}
]
]
]
}
}
]
}
},
"functions": [
{
"filter": {
"match": {
"cas_code.keyword": "富士"
}
},
"weight": 20
}
]
}
}
}
对不起,我的查询大约是5000行,并且我删除了很多东西要发布在StackOverFlow上。大约有20个query_string块,它们是全半角字符之间的转换的混合。请帮助改善此问题