I'm trying to understand the impact of the element word positions index setting.
See the following xquery which returns the plan of a simple element-word-query search:
xdmp:plan(cts:search(doc(),
cts:and-query(
cts:element-word-query(xs:QName("name"), "element word position")
),
("unfiltered")
))
And the final-plan if the index is not activated (reduced form to save space):
<qry:and-query>
<qry:term-query>element(name),pair(word("element"),word("word"))</qry:term-query>
<qry:term-query>element(name),pair(word("word"),word("position"))</qry:term-query>
<qry:term-query>word("element")</qry:term-query>
<qry:term-query>word("word")</qry:term-query>
<qry:term-query>word("position")</qry:term-query>
</qry:and-query>
Query plan after the index is activated (word-positions and also element word positions):
<qry:and-query>
<qry:term-query>element(name),pair(word("element"),word("word"))</qry:term-query>
<qry:term-query>element(name),pair(word("word"),word("position"))</qry:term-query>
<qry:element-query>
element(name)
<qry:word-query>
<qry:KP pos="0">word("element")</qry:KP>
<qry:KP pos="1">word("word")</qry:KP>
<qry:KP pos="2">word("position")</qry:KP>
</qry:word-query>
</qry:element-query>
</qry:and-query>
So i assume, because there are a lot less term-query generated, the resulting candidate fragment id count is going to be smaller and thus the intersection at index resolution is faster. Other than that i'd really like to understand how a element-query works under the hood. So i've got a few questions:
- What kind of additional information is saved in the index if
element word positionsis activated? - How would the index and posting list look like? Is the key only the element or a element+word combination? Are there any graphical resources which visualize it? (not expection you to draw something)
- Also how does a
element-queryexecute? I see how a simpleterm-queryreturns the posting list of the term key, but i am not sure how aelement-querywith aword-queryas a "sub-query" is evalutated.
Edit:
Added a picture to visualize my understanding of how the index might look with element word positions enabled. (See mholstege's answers comments for details)
