return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>c# - Elastic Search Boost Query - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Elastic Search Boost Query - Stack Overflow

programmeradmin1浏览0评论

I have query like this:

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "IsDeleted": {
              "value": false
            }
          }
        },
        {
          "query_string": {
            "fields": [
              "FirstName^10",
              "LastName^10",
              "CompanyName^5",
              "MobilePhone^3",
              "MobilePhone^4",
              "ContactName^3",
              "CompanyName^3",
              "ContactMobilePhoneSearch^2",
              "CompanyName^2",
            ],
            "query": "/محمد(.*?)/ AND /محمد(ی|ي|ئ)(.*?)/"
          }
        }
      ]
    }
  },
  "size": 30,
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

as you can see I'm trying to use Field boosting using (^), now imagine I'm trying to search For 'xxx'. in the database i have this value in the FirstName Field and when i apply this query i would expect to see the result at the top 100 because i set the "FirstName^10" like this.

now i dont know why i dont get the correct result.

I have query like this:

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "IsDeleted": {
              "value": false
            }
          }
        },
        {
          "query_string": {
            "fields": [
              "FirstName^10",
              "LastName^10",
              "CompanyName^5",
              "MobilePhone^3",
              "MobilePhone^4",
              "ContactName^3",
              "CompanyName^3",
              "ContactMobilePhoneSearch^2",
              "CompanyName^2",
            ],
            "query": "/محمد(.*?)/ AND /محمد(ی|ي|ئ)(.*?)/"
          }
        }
      ]
    }
  },
  "size": 30,
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

as you can see I'm trying to use Field boosting using (^), now imagine I'm trying to search For 'xxx'. in the database i have this value in the FirstName Field and when i apply this query i would expect to see the result at the top 100 because i set the "FirstName^10" like this.

now i dont know why i dont get the correct result.

Share Improve this question asked Jan 31 at 13:15 HassanJalaliHassanJalali 13112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It's because of how the BM25 algorithm works. Check the following article. https://www.elastic.co/blog/practical-bm25-part-2-the-bm25-algorithm-and-its-variables.

In addition, please check the explain API call to understand "how elasticsearch scoring works?". https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html

An example:

GET /my-index-000001/_explain/0
{
  "query" : {
    "match" : { "message" : "elasticsearch" }
  }
}

or

GET /my-index-000001/_search
{
  "explain": true,
  "query" : {
    "match" : { "message" : "elasticsearch" }
  }
}
发布评论

评论列表(0)

  1. 暂无评论