# How to complete disable TF-IDF?

**URL:** <https://discuss.elastic.co/t/how-to-complete-disable-tf-idf/70570>\
**Category:** Elasticsearch\
**Created:** [January 4, 2017, 3:19pm UTC](https://discuss.elastic.co/t/how-to-complete-disable-tf-idf/70570 "2017-01-04T15:19:05Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![sdauletau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sdauletau/32/24779_2.png) [@sdauletau](https://discuss.elastic.co/u/sdauletau)\
**Post date:** [January 9, 2017, 7:49pm UTC](https://discuss.elastic.co/t/how-to-complete-disable-tf-idf/70570/4 "2017-01-09T19:49:56Z")

</div>

As I said, take a look at function score query. It allows to replace internal score.

```
curl -s -XDELETE "http://localhost:9200/test_index"

curl -s -XPUT "http://localhost:9200/test_index" -d '
{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "number_of_replicas": 0,
      "similarity": {
        "default": {
          "type": "classic"
        }
      }
    }
  }
}
'

curl -XPUT 'localhost:9200/test_index/test_type/_mapping' -d '
{
  "test_type": {
    "properties": {
      "field1": {
        "type": "text"
      },
      "field2": {
        "type": "text"
      }
    }
  }
}
'

curl -s -XPUT "localhost:9200/test_index/test_type/1" -d '
{"field1" : "bar foo", "field2" : "bar"}
'

curl -s -XPUT "localhost:9200/test_index/test_type/2" -d '
{"field1" : "bar bar bar", "field2" : "foo foo foo"}
'

curl -s -XPUT "localhost:9200/test_index/test_type/3" -d '
{"field1" : "bar bar foo foo", "field2" : "bar bar foo foo"}
'

curl -s -XPOST "http://localhost:9200/test_index/_refresh"

echo
echo
echo 'expecting doc 3 to have score 7.0'

curl -s "localhost:9200/test_index/test_type/_search?pretty=true" -d '
{
  "explain": false,
  "query": {
    "bool": {
      "disable_coord": true,
      "should": [
        {
          "function_score": {
            "boost": "1.0",
            "weight": "2.0",
            "boost_mode": "replace",
            "query": {
              "bool": {
                "filter": {
                  "match": {
                    "field1": {
                      "query": "foo"
                    }
                  }
                }
              }
            }
          }
        },
        {
          "function_score": {
            "boost": "1.0",
            "weight": "5.0",
            "boost_mode": "replace",
            "query": {
              "bool": {
                "filter": {
                  "match": {
                    "field2": {
                      "query": "foo"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}
'
```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-complete-disable-tf-idf/70570)._
