ES indexing and scaling question


(msya) #1

In my web app, there are various communities. These communities have groups
and the groups contain posts. A user could view posts in groups that he or
she is a member of. When a user searches for a post, they will be able to
provide a keyword, group id, user id, posted after date, and the number of
queries they want returned. So, I want to index the information in such a
way that it is scalable and the queries are faster.

This is how I am currently indexing information:

_index: community_id_113
_type: question
group_id : 150
post_date : 2012-8-1T15:12:25
message : "Hello. How are you?"
attachment : null

For each community, I am creating an index. I am indexing a question or
reply into the community index with a question or reply type.

If a user just enters a keyword, the search should be in groups that the
user is a member of. So, this is my query for it:

curl 'localhost:9200/community_id_113/question/_search?pretty=true' -d '
{
"query": {
"filtered": {
"query": {
"queryString": {
"default_field": "message",
"query": "hello"
}
},
"filter": {
"bool": {
"should": [
{
"term": {
"group_id": "150"
}
},
{
"term": {
"group_id": "151"
}
}
],
"must": {
"numeric_range": {
"post_date": {
"from": "2009-01-01",
"to": "2012-09-01"
}
}
}
}
}
}
}
}'

In the should clause, I am going to have all the group_ids that the user is
member of. So, the example above has only 2 group_ids, but there will be
many more. Will that query be slow if there are many group ids?

--


(system) #2