# Can some let know how to write below query in elasticsearch

**URL:** <https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789>\
**Category:** Elasticsearch\
**Created:** [July 17, 2015, 10:51am UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789 "2015-07-17T10:51:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaniaravinda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vaniaravinda](https://discuss.elastic.co/u/vaniaravinda)\
**Post date:** [July 17, 2015, 10:51am UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/1 "2015-07-17T10:51:25Z")

</div>

(  
(  
TITLE:"same old song and \\(dance)"^100  
OR (  
TITLE:same~0.8 AND TITLE:old~0.8 AND TITLE:song~0.8 AND TITLE:and~0.8 AND TITLE:??dance?~0.8  
)^50  
OR (  
TITLE:same~0.5 AND TITLE:old~0.5 AND TITLE:song~0.5 AND TITLE:and~0.5 AND TITLE:??dance?~0.5  
)^10  
OR TITLE:"same old song and \"~3^7  
)^500  
AND (  
COMPOSERS:perry ~2^2 OR COMPOSERS:tallarico ~2^2 OR COMPOSERS:perry, tallarico~2^2  
)  
)^100

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [July 17, 2015, 11:40am UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/2 "2015-07-17T11:40:49Z")

</div>

You could use it as-is with the `query_string` query but I assume you are trying to use the DSL. What specific issue are you encountering?

---

<div class="post-metadata">

**Author:** ![vaniaravinda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vaniaravinda](https://discuss.elastic.co/u/vaniaravinda)\
**Post date:** [July 27, 2015, 12:38pm UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/3 "2015-07-27T12:38:21Z")

</div>

Hi @jpountz,

TanQ for ur reply. But I want to run this query through .Net code. Before that I want to test the query through Sense. Can u plz let me know how to write this query for running in Sense.

Thanks,  
Vani Aravinda

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [July 27, 2015, 4:26pm UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/4 "2015-07-27T16:26:25Z")

</div>

This should look something like this:

```auto
GET my_index/_search
{
  "query": {
    "query_string": {
      "query": "( ( TITLE:\"same old song and \\(dance)\"^100 OR ( TITLE:same~0.8 AND TITLE:old~0.8 AND TITLE:song~0.8 AND TITLE:and~0.8 AND TITLE:??dance?~0.8 )^50 OR ( TITLE:same~0.5 AND TITLE:old~0.5 AND TITLE:song~0.5 AND TITLE:and~0.5 AND TITLE:??dance?~0.5 )^10 OR TITLE:\"same old song and \"~3^7 )^500 AND ( COMPOSERS:perry ~2^2 OR COMPOSERS:tallarico ~2^2 OR COMPOSERS:perry, tallarico~2^2 ) )^100"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![vaniaravinda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vaniaravinda](https://discuss.elastic.co/u/vaniaravinda)\
**Post date:** [July 28, 2015, 4:23am UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/5 "2015-07-28T04:23:25Z")

</div>

Hi @jpountz,

TanQ for ur quick reply. I'm able to run the query as u suggested. But Fuzziness '~' is not working if I write query like that. Is there anything I'm missing. Plz let me know.

Thanks,  
Vani Aravinda

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [July 28, 2015, 6:52am UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/6 "2015-07-28T06:52:11Z")

</div>

Can you elaborate on what is not working?

---

<div class="post-metadata">

**Author:** ![vaniaravinda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vaniaravinda](https://discuss.elastic.co/u/vaniaravinda)\
**Post date:** [July 28, 2015, 9:07am UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/7 "2015-07-28T09:07:16Z")

</div>

Hi @jpountz,

There was a slight mistake in query. I changed it and now it is working fine.

Thanks,  
Vani Aravinda

---

<div class="post-metadata">

**Author:** ![vaniaravinda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vaniaravinda](https://discuss.elastic.co/u/vaniaravinda)\
**Post date:** [July 28, 2015, 9:11am UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/8 "2015-07-28T09:11:37Z")

</div>

Hi @jpountz

I found in one of the article that Boost is Deprecated in 1.0.0.RC1. See Function score instead of boost. Can you please let me know how to use the Function score in my above query.

Thanks,  
Vani Aravinda

---

<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:** [July 5, 2017, 11:58pm UTC](https://discuss.elastic.co/t/can-some-let-know-how-to-write-below-query-in-elasticsearch/25789/9 "2017-07-05T23:58:40Z")

</div>


