# Newbie question: How to search for documents with routing?

**URL:** <https://discuss.elastic.co/t/newbie-question-how-to-search-for-documents-with-routing/8167>\
**Category:** Elasticsearch\
**Created:** [June 20, 2012, 11:11am UTC](https://discuss.elastic.co/t/newbie-question-how-to-search-for-documents-with-routing/8167 "2012-06-20T11:11:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngocvo3103](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@ngocvo3103](https://discuss.elastic.co/u/ngocvo3103)\
**Post date:** [June 20, 2012, 11:11am UTC](https://discuss.elastic.co/t/newbie-question-how-to-search-for-documents-with-routing/8167/1 "2012-06-20T11:11:27Z")

</div>

Hi all,

I have a scenario like this:

- I have a e-commerce site, and I get thousands users on it. Each user sells thousands items. I decided to create a route for each user, and all the items that belong to this user will use the same route with the user.  
So, I created something like this:

# ================================================================================ { "index" : { "\_index" : "ecommerce", "\_type" : "users", "\_routing":"sammy" } } { "user" : "sammy", "email":"sammy@abc.com", "type":"seller" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"sammy" } } { "name" : "Pencil", "post\_time":"06-12-2012", "message":"Selling pencils", "price":"$0.2" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"sammy" } } { "name" : "Notebook", "post\_time":"06-14-2012", "message":"Selling notebooks", "price":"$0.5" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"sammy" } } { "name" : "Ruler", "post\_time":"06-16-2012", "message":"Selling rulers", "price":"$0.2" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"sammy" } } { "name" : "Eraser", "post\_time":"06-20-2012", "message":"Selling erasers", "price":"$0.1" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"sammy" } } { "name" : "Pen", "post\_time":"05-14-2012", "message":"Selling pens", "price":"$0.3" } { "index" : { "\_index" : "ecommerce", "\_type" : "users", "\_routing":"nigel" } } { "user" : "nigel", "email":"nigel@abc.com", "type":"seller" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"nigel" } } { "name" : "Pencil", "post\_time":"06-12-2012", "message":"Selling pencils", "price":"$0.2" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"nigel" } } { "name" : "Notebook", "post\_time":"06-14-2012", "message":"Selling notebooks", "price":"$0.5" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"nigel" } } { "name" : "Ruler", "post\_time":"06-16-2012", "message":"Selling rulers", "price":"$0.2" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"nigel" } } { "name" : "Eraser", "post\_time":"06-20-2012", "message":"Selling erasers", "price":"$0.1" } { "index" : { "\_index" : "ecommerce", "\_type" : "items", "\_routing":"nigel" } } { "name" : "Pen", "post\_time":"05-14-2012", "message":"Selling pens", "price":"$0.3" }

Now, I want to search all the items that belong to some user, let say "sammy". What should I do?

I've read this guide "[http://www.elasticsearch.org/guide/reference/api/search/](http://www.elasticsearch.org/guide/reference/api/search/)" and some other posts but still not find the solution. Could you guys please help me to query in this case? I appreciate all your helps.

Regards,  
Sam Vo

---

<div class="post-metadata">

**Author:** ![ngocvo3103](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@ngocvo3103](https://discuss.elastic.co/u/ngocvo3103)\
**Post date:** [June 21, 2012, 11:06am UTC](https://discuss.elastic.co/t/newbie-question-how-to-search-for-documents-with-routing/8167/2 "2012-06-21T11:06:53Z")

</div>

Hi again,

I'm sorry for such a noob question like that. Now i understand the concept of routing 🙂

Regards,  
Sam

---

<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 6, 2017, 3:23am UTC](https://discuss.elastic.co/t/newbie-question-how-to-search-for-documents-with-routing/8167/3 "2017-07-06T03:23:06Z")

</div>


