I need to query a document library to get items associated with some taxonomy terms, or items with specific documentId (site collection scoped feature, not the integer ID of the item), but the whole query doesn't give me the expected result but each separated block does.
Here's the full query :
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE"/>
</OrderBy>
<Where>
<Or>
<Or>
<Or>
<Or>
<Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3726</Value>
</Eq>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3731</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3727</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3732</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3728</Value>
</Eq>
</Or>
<And>
<In>
<FieldRef Name="WATSON_GED_META__xTaxonomy" LookupId="True" />
<Values>
<Value Type="Integer">0</Value>
<Value Type="Integer">1</Value>
<Value Type="Integer">2</Value>
<Value Type="Integer">230</Value>
<Value Type="Integer">263</Value>
<Value Type="Integer">270</Value>
<Value Type="Integer">376</Value>
<Value Type="Integer">377</Value>
<Value Type="Integer">378</Value>
<Value Type="Integer">379</Value>
</Values>
</In>
<BeginsWith>
<FieldRef Name="ContentTypeId"/>
<Value Type="Text">0x0101</Value>
</BeginsWith>
</And>
</Or>
</Where>
This query just give me the documents tagged with specified taxonomy terms (wssId), but none of the items with the specified DocumentIds in the nested "Or".
On the other side, this query (let's call it Query1) gives me the 5 items :
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE"/>
</OrderBy>
<Where>
<Or>
<Or>
<Or>
<Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3726</Value>
</Eq>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3731</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3727</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3732</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name="_dlc_DocId"/>
<Value Type="Text">7JFXJRWQRFV7-3-3728</Value>
</Eq>
</Or>
</Where>
and this one (let's call it Query2) gives me 90 items :
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE"/>
</OrderBy>
<Where>
<And>
<In>
<FieldRef Name="WATSON_GED_META__xTaxonomy" LookupId="True" />
<Values>
<Value Type="Integer">0</Value>
<Value Type="Integer">1</Value>
<Value Type="Integer">2</Value>
<Value Type="Integer">230</Value>
<Value Type="Integer">263</Value>
<Value Type="Integer">270</Value>
<Value Type="Integer">376</Value>
<Value Type="Integer">377</Value>
<Value Type="Integer">378</Value>
<Value Type="Integer">379</Value>
</Values>
</In>
<BeginsWith>
<FieldRef Name="ContentTypeId"/>
<Value Type="Text">0x0101</Value>
</BeginsWith>
</And>
</Where>
So the union of those two queries should give me 95 items (the 5 items given by Query1 are not tagged with any of the taxonomy terms of Query2) but only gives me the same 90 items that Query2 returns. The full query seems to ignore the nested "Or". This query is however syntactically correct...
Is there some undocumented limitations querying on taxonomy fields? Could someone tell me what's wrong with my query and how I could do to make it work as expected ? I already tried to replace the "In" element with nested "Or" but in some case I have so many taxonomy wssIds (more than 200 nested "Or") that the query crashes.
Thanks.