# Using constant\_score to avoid TF-IDF

**URL:** <https://discuss.elastic.co/t/using-constant-score-to-avoid-tf-idf/152239>\
**Category:** Elasticsearch\
**Created:** [October 12, 2018, 12:43pm UTC](https://discuss.elastic.co/t/using-constant-score-to-avoid-tf-idf/152239 "2018-10-12T12:43:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![madhurtelang](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@madhurtelang](https://discuss.elastic.co/u/madhurtelang)\
**Post date:** [October 12, 2018, 12:43pm UTC](https://discuss.elastic.co/t/using-constant-score-to-avoid-tf-idf/152239/1 "2018-10-12T12:43:24Z")

</div>

Hi,

I have a use case of resume screening candidates based on job description keywords. Since I cannot afford change in score each time a new candidate profile is added to the content list (I assume IDF will change), I want to omit TF\_IDF. As per the [documentation](https://www.elastic.co/guide/en/elasticsearch/guide/current/ignoring-tfidf.html), I created this query

> ```
> {
> "query": {
> "bool": {
> "should": [
> { "constant_score": {
> "query": { "match": { "description": "corporate strategy" }}
> }},
> { "constant_score": {
> "query": { "match": { "description": "strategy consulting" }}
> }},
> { "constant_score": {
> "query": { "match": { "description": "international strategy" }}
> }},
> { "constant_score": {
> "query": { "match": { "description": "MBA" }}
> }}
> ]
> }
> }
> }
> 
> ```

The issue is I am getting error

`[constant_score] query does not support [query]`

All I want is a simple score of 1 for single-or-n occurrence for each term. Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![madhurtelang](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@madhurtelang](https://discuss.elastic.co/u/madhurtelang)\
**Post date:** [October 12, 2018, 7:43pm UTC](https://discuss.elastic.co/t/using-constant-score-to-avoid-tf-idf/152239/2 "2018-10-12T19:43:09Z")

</div>

SOLVED.

The documentation was for 2.x version. As per 6.4.x version, following should work

```
{
  "query": {
    "bool": {
      "should": [
        { "constant_score": {
          "filter": { "match": { "description": "corporate strategy" }}
        }},
        { "constant_score": {
          "filter": { "match": { "description": "strategy consulting" }}
        }},
        { "constant_score": {
          "filter": { "match": { "description": "international strategy" }}
        }},
        { "constant_score": {
          "filter": { "match": { "description": "MBA" }}
        }}
      ]
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 9, 2018, 7:54pm UTC](https://discuss.elastic.co/t/using-constant-score-to-avoid-tf-idf/152239/3 "2018-11-09T19:54:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
