elasticsearch 提升查询速度

发布于 2024-12-05 00:43:20 字数 3708 浏览 1 评论 0原文

这是一个非常新手的问题,但我想了解如何 增强文档中的某些元素是有效的。

我从这个查询开始,

{
  "from": 0,
  "size": 6,
  "fields": [
    "_id"
  ],
  "sort": {
    "_score": "desc",
    "vendor.name.stored": "asc",
    "item_name.stored": "asc"
  },
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "fields": [
            "_all"
          ],
          "query": "Calprotectin",
          "default_operator": "AND"
        }
      },
      "filter": {
        "and": [
          {
            "query": {
              "query_string": {
                "fields": [
                  "targeted_countries"
                ],
                "query": "All US"
              }
            }
          }
        ]
      }
    }
  }
}

然后我需要比其他元素更多地提升文档中的某些元素 所以我这样做后

{
  "from": 0,
  "size": 60,
  "fields": [
    "_id"
  ],
  "sort": {
    "_score": "desc",
    "vendor.name.stored": "asc",
    "item_name.stored": "asc"
  },
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "fields": [
            "item_name^4",
            "vendor^4",
            "id_plus_name",
            "category_name^3",
            "targeted_countries",
            "vendor_search_name^4",
            "AdditionalProductInformation^0.5",
            "AskAScientist^0.5",
            "BuyNowURL^0.5",
            "Concentration^0.5",
            "ProductLine^0.5",
            "Quantity^0.5",
            "URL^0.5",
            "Activity^1",
            "Form^1",
            "Immunogen^1",
            "Isotype^1",
            "Keywords^1",
            "Matrix^1",
            "MolecularWeight^1",
            "PoreSize^1",
            "Purity^1",
            "References^1",
            "RegulatoryStatus^1",
            "Specifications/Features^1",
            "Speed^1",
            "Target/MoleculeDescriptor^1",
            "Time^1",
            "Description^2",
            "Domain/Region/Terminus^2",
            "Method^2",
            "NCBIGeneAliases^2",
            "Primary/Secondary^2",
            "Source/ExpressionSystem^2",
            "Target/MoleculeSynonym^2",
            "Applications^3",
            "Category^3",
            "Conjugate/Tag/Label^3",
            "Detection^3",
            "GeneName^3",
            "Host^3",
            "ModificationType^3",
            "Modifications^3",
            "MoleculeName^3",
            "Reactivity^3",
            "Species^3",
            "Target^3",
            "Type^3",
            "AccessionNumber^4",
            "Brand/Trademark^4",
            "CatalogNumber^4",
            "Clone^4",
            "entrezGeneID^4",
            "GeneSymbol^4",
            "OriginalItemName^4",
            "Sequence^4",
            "SwissProtID^4",
            "option.AntibodyProducts^4",
            "option.AntibodyRanges&Modifications^1",
            "option.Applications^4",
            "option.Conjugate^3",
            "option.GeneID^4",
            "option.HostSpecies^3",
            "option.Isotype^3",
            "option.Primary/Secondary^2",
            "option.Reactivity^4",
            "option.Search^1",
            "option.TargetName^1",
            "option.Type^4"
          ],
          "query": "Calprotectin",
          "default_operator": "AND"
        }
      },
      "filter": {
        "and": [
          {
            "query": {
              "query_string": {
                "fields": [
                  "targeted_countries"
                ],
                "query": "All US"
              }
            }
          }
        ]
      }
    }
  }
} 

查询速度大大减慢,我这样做正确吗?有没有一个 加快速度的方法?我目前正在对文档进行索引时进行提升,但在查询中使用它最适合我的应用程序的运行方式。非常感谢任何帮助

this is a very novice question but I'm trying to understand how
boosting certain elements in a document works.

I started with this query,

{
  "from": 0,
  "size": 6,
  "fields": [
    "_id"
  ],
  "sort": {
    "_score": "desc",
    "vendor.name.stored": "asc",
    "item_name.stored": "asc"
  },
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "fields": [
            "_all"
          ],
          "query": "Calprotectin",
          "default_operator": "AND"
        }
      },
      "filter": {
        "and": [
          {
            "query": {
              "query_string": {
                "fields": [
                  "targeted_countries"
                ],
                "query": "All US"
              }
            }
          }
        ]
      }
    }
  }
}

then i needed to boost certain elements in the document more than the others
so I did this

{
  "from": 0,
  "size": 60,
  "fields": [
    "_id"
  ],
  "sort": {
    "_score": "desc",
    "vendor.name.stored": "asc",
    "item_name.stored": "asc"
  },
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "fields": [
            "item_name^4",
            "vendor^4",
            "id_plus_name",
            "category_name^3",
            "targeted_countries",
            "vendor_search_name^4",
            "AdditionalProductInformation^0.5",
            "AskAScientist^0.5",
            "BuyNowURL^0.5",
            "Concentration^0.5",
            "ProductLine^0.5",
            "Quantity^0.5",
            "URL^0.5",
            "Activity^1",
            "Form^1",
            "Immunogen^1",
            "Isotype^1",
            "Keywords^1",
            "Matrix^1",
            "MolecularWeight^1",
            "PoreSize^1",
            "Purity^1",
            "References^1",
            "RegulatoryStatus^1",
            "Specifications/Features^1",
            "Speed^1",
            "Target/MoleculeDescriptor^1",
            "Time^1",
            "Description^2",
            "Domain/Region/Terminus^2",
            "Method^2",
            "NCBIGeneAliases^2",
            "Primary/Secondary^2",
            "Source/ExpressionSystem^2",
            "Target/MoleculeSynonym^2",
            "Applications^3",
            "Category^3",
            "Conjugate/Tag/Label^3",
            "Detection^3",
            "GeneName^3",
            "Host^3",
            "ModificationType^3",
            "Modifications^3",
            "MoleculeName^3",
            "Reactivity^3",
            "Species^3",
            "Target^3",
            "Type^3",
            "AccessionNumber^4",
            "Brand/Trademark^4",
            "CatalogNumber^4",
            "Clone^4",
            "entrezGeneID^4",
            "GeneSymbol^4",
            "OriginalItemName^4",
            "Sequence^4",
            "SwissProtID^4",
            "option.AntibodyProducts^4",
            "option.AntibodyRanges&Modifications^1",
            "option.Applications^4",
            "option.Conjugate^3",
            "option.GeneID^4",
            "option.HostSpecies^3",
            "option.Isotype^3",
            "option.Primary/Secondary^2",
            "option.Reactivity^4",
            "option.Search^1",
            "option.TargetName^1",
            "option.Type^4"
          ],
          "query": "Calprotectin",
          "default_operator": "AND"
        }
      },
      "filter": {
        "and": [
          {
            "query": {
              "query_string": {
                "fields": [
                  "targeted_countries"
                ],
                "query": "All US"
              }
            }
          }
        ]
      }
    }
  }
} 

the query slowed down considerably, am I doing this correctly? Is there a
way to speed it up? I'm currently in the process of doing the boosting when I index the document, but using it in the query that way is best for the way my application runs. Any help is much appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泛泛之交 2024-12-12 00:43:20

查询时间提升用于为术语分配更大的权重。如果您想永久提升字段,请使用索引时间提升 。如果您不想一直使用此增强功能,则可以通过设置 store: "no" 为其创建单独的映射。

Query time boosting is used for assigning larger weight to a term. If you want to permanently boost a field, use index time boosting. If you don't want to use this boosting all the time, then it makes sense to create a separate mapping just for it with store: "no" set.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文