It's something I learned with SQL. Systems sometimes choose to omit nulls from indexes, because there's no value to index. When this causes performance problems for FOO=null lookups, you use a trick. Instead of actually using null, use a placeholder value. For example if you were using integer amounts for a transaction ledger, you might decide to use 0 as a placeholder. Or with a string you might use "", or a special dummy value that would never occur in real data.
In XQuery we don't have "null" - but an empty sequence is similar in many ways. So we can apply a similar solution: instead of omitting an element, insert it with a placeholder value. Then use that placeholder value in queries. That's what I meant by "materializing" nulls. -- Mike On 24 Sep 2013, at 02:46 , Rachel Wilson <[email protected]> wrote: > Excuse me, but what does it mean to "materialize"? > > I couldnt find anything when searching for the term on developer.marklogic.com > > Rachel > ________________________________________ > From: [email protected] > [[email protected]] on behalf of Michael Blakeley > [[email protected]] > Sent: Sunday, September 22, 2013 6:10 PM > To: MarkLogic Developer Discussion > Subject: Re: [MarkLogic Dev General] cts:element-values > > Usually it's best to materialize nulls. That way they can be indexed. > > -- Mike > > On 22 Sep 2013, at 21:43 , Gontla Praveen <[email protected]> > wrote: > >> Hi All, >> >> Can someone suggest me why cts:element-values will count null values also. >> >> Below is the same scenario which i came across of. >> declare namespace pr="http://www.w3schools.com"; >> let $query := cts:directory-query("/onlinedocs/") >> let $vals := >> cts:element-values(xs:QName("pr:filtervalue"),(),("collation=http://sample.com")$query) >> >> return for $i in $vals >> return <filter value="{$i}">{cts:frequency($i)}</filter> >> >> The above value returns me all distinct values that are available in my DB >> under the element pr:filtervalue including null value. >> >> Below is the sample $vals response: >> >> <filter value="online">40</filter> >> <filter value="online_new">90</filter> >> <filter value="offline">50</filter> >> <filter value="offline_new">20</filter> >> <filter value="">40</filter> >> >> Thanks in Advance >> >> Thanks, >> Praveen >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > > > ----------------------------- > http://www.bbc.co.uk > This e-mail (and any attachments) is confidential and > may contain personal views which are not the views of the BBC unless > specifically stated. > If you have received it in > error, please delete it from your system. > Do not use, copy or disclose the > information in any way nor act in reliance on it and notify the sender > immediately. > Please note that the BBC monitors e-mails > sent or received. > Further communication will signify your consent to > this. > ----------------------------- > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
