I assume you have created multilist field on documents and data-source of the multilist field is Category items.
Now if you select 1,3 and 4 categories into mulitlist of document 1 and 2 ,6 & 7 categories for document d2 multilist field.
On the front end you have checkboxes or any other thing for select categories now if you are selecting 1 and 2 then both document will show right?
If this is the requirement then you can handle this by creating predicate builder and you can pass pipe separated categories into predicate builder as below code -
var builder = PredicateBuilder.True();
//Filter with TemplateId
builder = builder.And(i => i.TemplateId == [TemplateId]);
//Created new builder for Category items and added again into main builder
if (!string.IsNullOrEmpty(Categorys))
{ var Categorybuilder = PredicateBuilder.False();
var CategoryItems = Categorys.Split('|');
foreach (var Category in CategoryItems)
{
var ct = Sitecore.ContentSearch.Utilities.IdHelper.NormalizeGuid(Categorys, true);
Categorybuilder = Categorybuilder.Or(i => i.Category.Contains(ct));
}
builder = builder.And(Categorybuilder);
}
Now pass this builder to search results query as below -
var results=context.GetQueryable().Where(builder).Select(i => (Item)i.GetItem()).ToList()
That way you can get the document values with OR.
For more details you can also have a look my post -
http://www.nttdatasitecore.com/Blog/2016/September/Sitecore-Lucene-Search-filtering-with-Predicate-Builder
In this post I have written same scenario with multiple filters.
Please let me know if something is not clear to you.