Combining routing and filter

I am having problems using a terms filter when I specify the routing value.
I'm indexing documents called "activities" routing by the user's ID. I
decided changing the default routing since I will always list activities by
the user ID, so I thought using this field as the routing value would be
useful. But when I execute the following command:

*curl
http://USER:PASS@192.168.0.1:8080/activity_index/activity/_search?routing=17
*

I get documents from more than one user. For example, activities from user
with ID = 1 are allocated in the same shard as activities from user with ID
= 6. So, to list only the activities from the user I want, I have to use a
terms filter, but it is not working.

I am using NEST (ES C# wrapper), so I don't know if it's a bug in NEST, or
if I am using it wrong, or if it's how elastic search works. Can anyone
answer me that?

The code I'm using with NEST is:

private static void Index(Activity activity)
{
GetClient().Index(activity, activityIndexName, "activity",
new IndexParameters() { Routing = activity.userID.ToString() });
}

public static IList ListUserActivities(int userID)
{
return GetClient().Search(s => s
.Routing(userID.ToString())
.Filter(q => q
.Term("userID", userID.ToString()))
).Documents.ToList();
}

I have to use a terms filter, but it is not working.

What does a real userID look like, and how is the userID mapped. I'm
betting that the field is just mapped as { type: "string" }, which means
that the value is being analyzed, and that your UIDs include capital
letters, which means that they are being stored lowercase.

A term filter won't work in this situation because you are searching for
"XYZ123" but the value that is stored is actually "xyz123"

You should set your userID to be:

{ type: "string", index: "not_analyzed" }

clint