Newbie question: How to search for documents with routing?

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/" 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

Hi again,

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

Regards,
Sam