File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
extensions/indexes/lucene/src
main/java/org/exist/indexing/lucene Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 5555import org .exist .dom .QName ;
5656import org .exist .indexing .lucene .analyzers .NoDiacriticsStandardAnalyzer ;
5757import org .exist .storage .NodePath ;
58+ import org .exist .storage .NodePath2 ;
5859import org .exist .util .DatabaseConfigurationException ;
5960import org .w3c .dom .Element ;
6061import org .w3c .dom .Node ;
@@ -127,6 +128,31 @@ public LuceneConfig(LuceneConfig other) {
127128 this .analyzers = other .analyzers ;
128129 this .facetsConfig = other .facetsConfig ;
129130 }
131+
132+ /**
133+ * Determines probabilistically if there might be a configured index
134+ * for the QName. False positive matches are possible,
135+ * but false negatives are not.
136+ *
137+ * @param qname the element/attribute to look for an index configuration for.
138+ *
139+ * @return true indicates that there might be a config, false indicates
140+ * that there definitely is not a config.
141+ */
142+ public boolean hasConfig (final QName qname ) {
143+ if (paths .containsKey (qname )) {
144+ return true ;
145+ } else {
146+ final NodePath2 path = new NodePath2 ();
147+ path .addComponent (qname );
148+ for (final LuceneIndexConfig config : wildcardPaths ) {
149+ if (config .match (path )) {
150+ return true ;
151+ }
152+ }
153+ }
154+ return false ;
155+ }
130156
131157 public boolean matches (final NodePath path ) {
132158 LuceneIndexConfig idxConf = paths .get (path .getLastComponent ());
Original file line number Diff line number Diff line change @@ -950,4 +950,28 @@ function facet:query-no-default-index-bracketed-element-count-and-facets() {
950950 let $result := doc ("/db/lucenetest/multi-lang.xml" )//(div )[ft:query (., "english:*" , map { "leading-wildcard" : "yes" })]
951951 return
952952 count ($result) || " " || ft:facets ($result, "language" )?en
953- };
953+ };
954+
955+ declare
956+ %test:assertEquals(1 )
957+ function facet:query-no-default-index-bracketed-element-one-nonexistent-element-count () {
958+ let $result := doc ("/db/lucenetest/multi-lang.xml" )//(div |other)[ft:query (., "english:*" , map { "leading-wildcard" : "yes" })]
959+ return
960+ count ($result)
961+ };
962+
963+ declare
964+ %test:assertEquals(1 )
965+ function facet:query-no-default-index-bracketed-element-one-nonexistent-element-facets () {
966+ let $result := doc ("/db/lucenetest/multi-lang.xml" )//(div |other)[ft:query (., "english:*" , map { "leading-wildcard" : "yes" })]
967+ return
968+ ft:facets ($result, "language" )?en
969+ };
970+
971+ declare
972+ %test:assertEquals("1 1" )
973+ function facet:query-no-default-index-bracketed-element-one-nonexistent-element-count-and-facets () {
974+ let $result := doc ("/db/lucenetest/multi-lang.xml" )//(div |other)[ft:query (., "english:*" , map { "leading-wildcard" : "yes" })]
975+ return
976+ count ($result) || " " || ft:facets ($result, "language" )?en
977+ };
You can’t perform that action at this time.
0 commit comments