lucenejackrabbit-oak

Difference between indexNodeName and :nodeName in OAK Lucene Index


What is the difference (if any) between setting indexNodeName=true on the node type definition and defining a virtual nodeName property with the attribute name=:nodeName. indexNodeName is defined as follows:

Default to false. If set to true then index would also be created for node name. This would enable faster evaluation of queries involving constraints on Node name

Index the nodename as property aims the be similar to indexNodeName, but this doesn't imply "the same as". The docs are not saying that much about this:

The string :nodeName - this special case indexes node name as if it’s a virtual property of the node being indexed. Setting this along with nodeScopeIndex=true is akin to setting indexNodeName=true on indexing rule.

So is it required to set both or only one of the settings in order to query the nodename. If just one of them, which one and what is the difference? Examples:

//element(*, app:Asset)[fn:name() = ‘kite’]
//*[jcr:like(fn:name(), ‘kite%’)]
//element(kite, app:Asset)
//element(*, dam:Asset)[(jcr:like(fn:lower-case(fn:name()), 'kite%')

Solution

  • indexNodeName=true is a shortcut to having a property definition with name=:nodeName AND nodeScopeIndex=true.

    The name=:nodeName allows for more flexibility (at the cost of a bit of complexity) to index node names for other usages too - suggestions, spellchecks, etc.

    So, if you just want to query for node names using either of the methods should work well (although, imo, indexNodeName=true is simpler and cleaner). Otoh, if you also want for node names to show up as suggestion/spellcheck results, then you'd have to resort to have a property definition with name=:nodeName AND nodeScopeIndex=true AND useInSuggest=true.