根据elasticsearch中的字段提升改进搜索结果

时间:2017-06-05 10:39:20

标签: vb.net elasticsearch

我第一次使用ElasticSearch 1.7,我根据字段设置了权重。它可能会根据要求而改变。我从查询中得到了结果,但问题是如果我大幅改变字段权重,那么我就无法看到对记录的影响。请查看我的以下查询,如果我做错了,请告诉我。

ElasticSearch查询:

{
   "from": 0,
   "size": 10,
   "highlight": {
      "pre_tags": [
         "<b>"
      ],
      "post_tags": [
         "</b>"
      ],
      "fields": {
         "title": {},
         "description": {}
      }
   },
   "query": {
      "function_score": {
         "query": {
            "query_string": {
               "query": "any keyword",
               "fields": [
                  "fullText",
                  "title^100",
                  "authors^4",
                  "pubYear^4",
                  "publisher^4",
                  "abstract^2",
                  "documentTypeName^2",
                  "topic^6",
                  "topicSynonym^6"
                  "quality_value^6",
                  "domain^2"
               ],
               "default_operator": "AND",
               "analyze_wildcard": true
            }
         },
         "score_mode": "sum",
         "boost_mode": "sum",
         "max_boost": 100
      }
   }
}

示例数据:

{
   "took": 44,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1465,
      "max_score": 14.961364,
      "hits": [
         {
            "_index": "snData",
            "_type": "report",
            "_id": "159",
            "_score": 14.961364,
            "_source": {
               "str_ID": "159",
               "topic": [
                  "strategy",
                  "Consumer-targeted strategy"
               ],
               "topicSynonym": [
                  "assistance",
                  "coping",
                  "coping strategies",
                  "encouragement",
                  "support"
               ],
               "fullText": "Background: As the incidence and prevalence of prostate cancer continue to rise, the number of men needing help and support to assist them in coping with disease and treatment-related symptoms and their psychosocial effects is likely to increase.",
               "quality_value": 1,
               "ID": 24034,
               "title": "Psychosocial interventions for men with prostate cancer",
               "authors": "Parahoo K E Noyes",
               "pubYear": "2013",
               "publisher": "",
               "abstractEN": "Background: As the incidence and prevalence of prostate cancer continue to rise, the number of men needing help and support to assist them in coping with disease and treatment-related symptoms and their psychosocial effects is likely to increase.",
               "uniqueID": "",
               "documentTypeName": "Review of effects",
               "viewCount": 28,
            },
            "highlight": {
               "title": [
                  "Interventions for men with prostate <b>cancer</b>"
               ],
               "abstract": [
                  "Background: As the incidence and prevalence of prostate <b>cancer</b> continue to rise, the number of men"
               ]
            }
         }
      ]
   }
}

使用案例:如果我更改了quality_value或其他任何人的权重,那么它应该根据字段权重更改结果。我不确定我的查询是否正确或我遗漏了什么。我正在使用ElasticSearch 1.7

0 个答案:

没有答案