# Using a document as reference to boost results?

**URL:** <https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848>\
**Category:** Elasticsearch\
**Created:** [May 3, 2020, 7:30am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848 "2020-05-03T07:30:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)\
**Post date:** [May 3, 2020, 7:30am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/1 "2020-05-03T07:30:44Z")

</div>

Hi,  
I was wondering whether there is a way I can feed additional text (from a document) to get more accurate results?  
For example, a user can upload a PDF that contains text that s/he thinks is relevant to the search. Then use something like TF-IDF to extract important words and feed them to something like a `should` query along with the actual query in a `must` query. Has anyone tried something like this? Has it worked? Any better way to achieve this?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 3, 2020, 8:04am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/2 "2020-05-03T08:04:25Z")

</div>

Have you looked at the [more like this query](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-mlt-query.html)?

---

<div class="post-metadata">

**Author:** ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)\
**Post date:** [May 4, 2020, 9:39am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/3 "2020-05-04T09:39:42Z")

</div>

Yes @Christian_Dahlqvist But can I use it along with a user entered query? I believe this is the query you are referring to:

```auto
GET /_search
{
    "query": {
        "more_like_this" : {
            "fields" : ["name.first", "name.last"],
            "like" : [
            {
                "_index" : "marvel",
                "doc" : {
                    "name": {
                        "first": "Ben",
                        "last": "Grimm"
                    },
                    "_doc": "You got no idea what I'd... what I'd give to be invisible."
                  }
            },
            {
                "_index" : "marvel",
                "_id" : "2"
            }
            ],
            "min_term_freq" : 1,
            "max_query_terms" : 12
        }
    }
}

```

I understand the part of feeding in the artificial document, but I want to combine that with a user-entered query. Where do I put that?

---

<div class="post-metadata">

**Author:** ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)\
**Post date:** [May 12, 2020, 2:43am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/4 "2020-05-12T02:43:12Z")

</div>

@Christian_Dahlqvist It would be great if you can find some time to look into this. Thanks!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 12, 2020, 5:09am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/5 "2020-05-12T05:09:28Z")

</div>

I am not sure it will get you where you want, but can’t you wrap this query and the user query in a Boolean query?

---

<div class="post-metadata">

**Author:** ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)\
**Post date:** [May 12, 2020, 6:09am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/6 "2020-05-12T06:09:13Z")

</div>

Something like the user query in a `must` clause and the extra keywords in a `should` clause?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 12, 2020, 6:18am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/7 "2020-05-12T06:18:05Z")

</div>

Yes, something like that could potentially work.

---

<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:** [June 9, 2020, 6:18am UTC](https://discuss.elastic.co/t/using-a-document-as-reference-to-boost-results/230848/8 "2020-06-09T06:18:10Z")

</div>

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