# Is there a way to use non-text fields for document similarity in ElasticSearch, such as dates or integers?

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-use-non-text-fields-for-document-similarity-in-elasticsearch-such-as-dates-or-integers/157018>\
**Category:** Elasticsearch\
**Created:** [November 16, 2018, 10:08am UTC](https://discuss.elastic.co/t/is-there-a-way-to-use-non-text-fields-for-document-similarity-in-elasticsearch-such-as-dates-or-integers/157018 "2018-11-16T10:08:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bolaft](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bolaft/32/37731_2.png) [@bolaft](https://discuss.elastic.co/u/bolaft)\
**Post date:** [November 16, 2018, 10:08am UTC](https://discuss.elastic.co/t/is-there-a-way-to-use-non-text-fields-for-document-similarity-in-elasticsearch-such-as-dates-or-integers/157018/1 "2018-11-16T10:08:22Z")

</div>

Using the more\_like\_this feature of ElasticSearch, I understand how to use tf-idf or other metrics to find similar documents based on text fields. However what if my use case is more like this:

```
# Name Description Price Date
--------------------------------------------
1 A B C Ba Bi Bou 100.0 12-01-18
--------------------------------------------
2 A B Z Ba Bi Xon 250.0 01-11-11
3 X Y Z Xa Xu Xon 100.0 12-02-18

```

Based on text fields only, document #2 should score higher than document #3 in terms of similarity with document #1, since document #3 would score 0. However, taking "price" and "date" into account, document #3's score should raise.

Can I do something like that with ElasticSearch? The only documentation I find deal with text fields. Adding non-text fields to the more\_like\_this query doesn't cause any exceptions, however scores are completely unaffected.

---

<div class="post-metadata">

**Author:** ![byronvoorbach](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/byronvoorbach/32/8283_2.png) [@byronvoorbach](https://discuss.elastic.co/u/byronvoorbach)\
**Post date:** [November 16, 2018, 1:51pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-use-non-text-fields-for-document-similarity-in-elasticsearch-such-as-dates-or-integers/157018/2 "2018-11-16T13:51:08Z")

</div>

As of this moment I don't think this is possible.  
From the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#_how_it_works):

> _Important_ : The fields on which to perform MLT must be indexed and of type `text` or `keyword`

---

<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:** [December 14, 2018, 1:51pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-use-non-text-fields-for-document-similarity-in-elasticsearch-such-as-dates-or-integers/157018/3 "2018-12-14T13:51:16Z")

</div>

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