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();
}