elasticsearch促进减缓查询

时间:2011-09-15 22:39:59

标签: elasticsearch

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

我从这个查询开始,

{
  "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"
              }
            }
          }
        ]
      }
    }
  }
} 

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

1 个答案:

答案 0 :(得分:2)

查询时间提升用于为术语分配更大的权重。如果要永久提升字段,请使用index time boosting。如果您不想一直使用此增强功能,那么仅使用store: "no"设置为其创建单独的映射是有意义的。