Each user in our app can see a subset of the documents based on a
number of conditions (permissions etc...) and I'm wondering what the
best approach to building a restricted query would be.
Andrei asked a similar question about restricting the query with
boolean vs filters in which filters came up as the most efficient
method:
http://elasticsearch-users.115913.n3.nabble.com/Boolean-query-vs-filters-and-more-td1177230.html;cid=1282670994600-452#a1182865
However in our data model we don't have a single field which we can
filter by, it's more a case of getting a list of all the IDs of
documents the user can access and then searching them.
Eg, modelled as a boolean query, which works but isn't very elegant
and I can see it having issues with performance as the query grows:
{
:query => {
:bool => {
:must => [
{
:query_string => {
:query => params[:q]
}
},
{
:query_string => {
:default_field => "id",
:query => accessible_ids.join(" OR ")
}
}
]
}
}
}
Is there a way of performing a term query against an array of terms so
that I could convert this to a filter?
Or is there a better way of doing this that someone knows of?
Thanks in advance.
--
Richard Livsey
Minutebase - Online Meeting Minutes
http://minutebase.com
http://livsey.org