Task #2678

Updated by Serge Heiden 10 months ago

Queries of type: @[_.sp_n="97"] [_.sp_n="97"] expand to sp@ sp
are very heavy.

There are some optimization in /org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/SubcorpusCQLQuery.java to avoid them when the part is of "text" level:

if ("text".equals(structure.getName())) { // optimisation only for the text structure
queryString = "<"+property.getFullName()+"=\""+CQLQuery.addBackSlash(value)+"\">[] expand to "+structure.getName();
} else {
queryString = "[_."+property.getFullName()+"=\""+CQLQuery.addBackSlash(value)+"\"] expand to "+structure.getName();

to generate a query of type: @<text_booktitle="Waterloo">[] <text_booktitle="Waterloo">[] expand to text@ text
Is there a way anyway to extend this optimization?
eg. @[_.sp_n="97"] [_.sp_n="97"] expand to sp@ sp
is equivalent to:
@<sp_n="97">[] <sp_n="97">[] expand to sp@ sp

NOTE: after discussion with MD, the 2 queries are not always equivalent. The optimized query "@<sp_n="97">[] "<sp_n="97">[] expand to sp@" sp" may not work on a subcorpus. But in the context of Part creation they may be always be equivalent?

h3. Solution 1

# 1) execute the query: @<sp_n="97">[] <sp_n="97">[] expand to sp@ sp
# 2) if no matches are found then execute the query: @[_.sp_n="97"] [_.sp_n="97"] expand to sp@ sp