# How to reverse search given a new document in the query in elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-reverse-search-given-a-new-document-in-the-query-in-elasticsearch/78855>\
**Category:** Elasticsearch\
**Created:** [March 16, 2017, 12:27pm UTC](https://discuss.elastic.co/t/how-to-reverse-search-given-a-new-document-in-the-query-in-elasticsearch/78855 "2017-03-16T12:27:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrinjalali](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@adrinjalali](https://discuss.elastic.co/u/adrinjalali)\
**Post date:** [March 16, 2017, 12:27pm UTC](https://discuss.elastic.co/t/how-to-reverse-search-given-a-new-document-in-the-query-in-elasticsearch/78855/1 "2017-03-16T12:27:38Z")

</div>

I asked this question here: [http://stackoverflow.com/questions/42830378/how-to-reverse-search-given-a-new-document-in-the-query-in-elasticsearch](http://stackoverflow.com/questions/42830378/how-to-reverse-search-given-a-new-document-in-the-query-in-elasticsearch)

But here it goes:

Here's the usecase:

I have a few types, let say city, country, music genre, music artist, etc., and given a sentence, I'd like to find all instances of any of those types in my given sentence.

How should I do it in Elasticsearch?

I'm thinking of putting the entities (city, country, etc.) each in a type, and then ideally, I'll give a sentence, and it would find all instances of them for me.

So for instance, if I have these:

```
city: [berlin, paris]
music-genre: [jazz, blues]

```

and I give the sentence "I like jazz festivals in berlin", then it should return me:

```
jazz: position X, score 1
berlin: position Y, score 1

```

So in a sense, instead of having `I like jazz festivals in berlin` as a document and then searching for `berlin` or `jazz`, the sentence is the query and `berlin` and `jazz` are the documents.

---

<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:** [April 13, 2017, 12:27pm UTC](https://discuss.elastic.co/t/how-to-reverse-search-given-a-new-document-in-the-query-in-elasticsearch/78855/2 "2017-04-13T12:27:41Z")

</div>

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