Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow index specification on qname instead of full path (to keep it c…

…ompatible with lucene index and old range index).
  • Loading branch information...
commit 3c7ec952409795a7b0d728ac0acab0e7da46a81c 1 parent 88af36a
@wolfgangmm wolfgangmm authored
View
2  extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexConfig.java
@@ -145,7 +145,7 @@ public boolean isInlineNode(QName qname) {
return specialNodes != null && specialNodes.get(qname) == N_INLINE;
}
- protected static QName parseQName(Element config, Map<String, String> namespaces) throws DatabaseConfigurationException {
+ public static QName parseQName(Element config, Map<String, String> namespaces) throws DatabaseConfigurationException {
String name = config.getAttribute(QNAME_ATTR);
if (name == null || name.length() == 0)
throw new DatabaseConfigurationException("Lucene index configuration error: element " + config.getNodeName() +
View
11 extensions/indexes/range/src/org/exist/indexing/range/RangeIndexConfigElement.java
@@ -4,6 +4,8 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
+import org.exist.dom.QName;
+import org.exist.indexing.lucene.LuceneIndexConfig;
import org.exist.storage.NodePath;
import org.exist.util.DatabaseConfigurationException;
import org.exist.xquery.XPathException;
@@ -17,13 +19,14 @@
protected NodePath path = null;
private int type = Type.STRING;
private RangeIndexConfigElement nextConfig = null;
+ private boolean isQNameIndex = false;
public RangeIndexConfigElement() {
}
public RangeIndexConfigElement(Element node, Map<String, String> namespaces) throws DatabaseConfigurationException {
String match = node.getAttribute("match");
- if (match != null) {
+ if (match != null && match.length() > 0) {
try {
path = new NodePath(namespaces, match);
if (path.length() == 0)
@@ -31,6 +34,10 @@ public RangeIndexConfigElement(Element node, Map<String, String> namespaces) thr
} catch (IllegalArgumentException e) {
throw new DatabaseConfigurationException("Range index module: invalid qname in configuration: " + e.getMessage());
}
+ } else if (node.hasAttribute("qname")) {
+ QName qname = LuceneIndexConfig.parseQName(node, namespaces);
+ path = new NodePath(qname);
+ isQNameIndex = true;
}
String typeStr = node.getAttribute("type");
if (typeStr != null && typeStr.length() > 0) {
@@ -179,6 +186,8 @@ public RangeIndexConfigElement getNext() {
}
public boolean match(NodePath other) {
+ if (isQNameIndex)
+ return other.getLastComponent().equalsSimple(path.getLastComponent());
return path.match(other);
}
View
16 extensions/indexes/range/test/src/xquery/range.xql
@@ -21,28 +21,29 @@ declare variable $rt:COLLECTION_CONFIG :=
<create match="/test/address/name"/>
<create match="/test/address/city" type="xs:string"/>
<create match="/test/address/city/@code" type="xs:integer"/>
+ <create qname="@id" type="xs:string"/>
</range>
</index>
</collection>;
declare variable $rt:DATA :=
<test>
- <address>
+ <address id="muh">
<name>Berta Muh</name>
<street>Wiesenweg 14</street>
<city code="65463">Almweide</city>
</address>
- <address>
+ <address id="rüssel">
<name>Rudi Rüssel</name>
<street>Elefantenweg 67</street>
<city code="65428">Rüsselsheim</city>
</address>
- <address>
+ <address id="amsel">
<name>Albert Amsel</name>
<street>Birkenstraße 77</street>
<city code="76878">Waldstadt</city>
</address>
- <address>
+ <address id="reh">
<name>Pü Reh</name>
<street>Am Waldrand 4</street>
<city code="89283">Wiesental</city>
@@ -99,6 +100,13 @@ function rt:equality-int-attribute($code as xs:integer) {
//address[range:equals(city/@code, $code)]/city/text()
};
+declare
+ %test:args("muh")
+ %test:assertEquals("Berta Muh")
+function rt:equality-qname-string-attribute($id as xs:string) {
+ //address[range:equals(@id, $id)]/name/text()
+};
+
declare
%test:args("Berta Muh")
%test:assertEquals("Almweide")
Please sign in to comment.
Something went wrong with that request. Please try again.