Thanks. Yes, this triggers full text search. I often break my queries into multiple variables though, particularly complex one. What should be a general design rule to leverage FT indexes?
It's difficult to give a general advice here, as the languages is just too complex; I'm frequently surprised how many alternatives exist to answer a single question with XQuery. However, If your query compiler won't manage to optimize your query for index access, you can always directly access the index structures by using our built-in XQuery functions db:fulltext(), db:attribute(), db:text(), ft:search(), etc. [1,2].
Christian
[1] http://docs.basex.org/wiki/Full-Text_Module [2] http://docs.basex.org/wiki/Database_Module#db:fulltext
On 11/25/11 1:53 PM, Christian Grün wrote:
Hi Pascal,
it often helps to simplify the query and re-check the info view. For example, you could try if one of the following queries benefit from the index:
[1] let $vars := /ddi:codeBook/ddi:dataDscr/ddi:var[ddi:labl contains text 'child'] return $vars/ddi:labl
[2] let $vars := /*:codeBook/*:dataDscr/*:var[*:labl contains text 'child'] return $vars/*:labl
[3] /*:codeBook/*:dataDscr/*:var[*:labl contains text 'child']/*:labl
Hope this helps, Christian
On Fri, Nov 25, 2011 at 7:31 PM, Pascal Heus pascal.heus@gmail.com wrote:
Christian and all: I have a similar question. When I execute the following query: declare namespace ddi = "http://www.icpsr.umich.edu/DDI"; let $allvars := /ddi:codeBook/ddi:dataDscr/ddi:var let $vars := $allvars[ddi:labl contains text 'child'] return $vars/ddi:labl my query plan does not seem to take advantage of the full text index (see below). Now I did enable full text search after loading the XML in the DB but performed and optimze and can see the FT active in the properties dialog. Does this make a difference? best *P
Query: declare namespace ddi = "http://www.icpsr.umich.edu/DDI"; Timing: - Parsing: 0.14 ms - Compiling: 0.15 ms - Evaluating: 1450.27 ms - Printing: 24.39 ms - Total Time: 1474.97 ms Result:
- Results: 3114 Items
- Updated: 0 Items
- Printed: 308 KB
Query plan:
<FLWR> <Let var="$allvars"> <IterPath> <Root/> <IterStep axis="child" test="ddi:codeBook"/> <IterStep axis="child" test="ddi:dataDscr"/> <IterStep axis="child" test="ddi:var"/> </IterPath> </Let> <Let var="$vars"> <IterFilter> <VarRef name="$allvars"/> <FTContains> <AxisPath> <IterStep axis="child" test="ddi:labl"/> </AxisPath> <FTWords> <Item value="child" type="xs:string"/> </FTWords> </FTContains> </IterFilter> </Let> <Return> <AxisPath> <VarRef name="$vars"/> <IterStep axis="child" test="ddi:labl"/> </AxisPath> </Return> </FLWR>