# Elastic search URI search to query object

**URL:** <https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367>\
**Category:** Elasticsearch\
**Created:** [February 21, 2020, 1:11pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367 "2020-02-21T13:11:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![arjun\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arjun_kumar/32/56852_2.png) [@arjun\_kumar](https://discuss.elastic.co/u/arjun_kumar)\
**Post date:** [February 21, 2020, 1:11pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/1 "2020-02-21T13:11:42Z")

</div>

GET `twitter/_search?q="11|2019|myName:user|testname|5b2b18f2-54ab-11ea-a2e3-2e728ce88125|A|M|testuser"`

when I run the above query able to get the exact results

even I tried GET `twitter/_search?q="11|2019|myName:user|testname|5b2b18f2-54ab-11ea-a2e3-2e728ce88125`

able to get all the proper results

if I want to query the same, from query object how can I build the query objecct  
**note:** my Id consists of special characters(example:11|2019|myName:user|testname|5b2b18f2-54ab-11ea-a2e3-2e728ce88125|A|M|testuser)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 21, 2020, 1:28pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/2 "2020-02-21T13:28:21Z")

</div>

What is the analyzer used?

---

<div class="post-metadata">

**Author:** ![arjun\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arjun_kumar/32/56852_2.png) [@arjun\_kumar](https://discuss.elastic.co/u/arjun_kumar)\
**Post date:** [February 21, 2020, 2:14pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/3 "2020-02-21T14:14:37Z")

</div>

this is "\_id", we did n't use any custom analyzers on it

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 21, 2020, 2:28pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/4 "2020-02-21T14:28:38Z")

</div>

Why do you want to search using the \_id field?

Why not

```
GET /twitter/_doc/11|2019|myName:user|testname|5b2b18f2-54ab-11ea-a2e3-2e728ce88125
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 21, 2020, 2:29pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/5 "2020-02-21T14:29:09Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![arjun\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arjun_kumar/32/56852_2.png) [@arjun\_kumar](https://discuss.elastic.co/u/arjun_kumar)\
**Post date:** [February 24, 2020, 7:38am UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/6 "2020-02-24T07:38:06Z")

</div>

we are using ES client and we want to query with other parameters too

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 24, 2020, 8:54am UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/7 "2020-02-24T08:54:40Z")

</div>

You can do a GET by id with a client as well.  
Could you share an example where you are querying both for \_id and another field?

Also please share a full example.

---

<div class="post-metadata">

**Author:** ![arjun\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arjun_kumar/32/56852_2.png) [@arjun\_kumar](https://discuss.elastic.co/u/arjun_kumar)\
**Post date:** [February 24, 2020, 4:37pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/8 "2020-02-24T16:37:22Z")

</div>

```
{
   "query":{
      "bool":{
         "must":[
            {
               "match":{
                  "status":"inProgress"
               }
            },
            {
               "query_string":{
                  "query":" (id:*12 AND \\| AND 2016 AND \\ |myName \\:user*) AND (userRole:*admin*) ",
                  "fields":[
                     "id",
                     "userRole"
                  ]
               }
            }
         ],
         "must_not":[
            {
               "match":{
                  "isDeleted":true
               }
            }
         ]
      }
   }
}
```

---

<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:** [March 23, 2020, 4:37pm UTC](https://discuss.elastic.co/t/elastic-search-uri-search-to-query-object/220367/9 "2020-03-23T16:37:35Z")

</div>

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