<commit_before>xquery version "3.0";

module namespace rt="http://exist-db.org/xquery/range/test/updates";

import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";

declare namespace mods="http://www.loc.gov/mods/v3";

declare variable $rt:COLLECTION := "/db/rangetest";

declare variable $rt:COLLECTION_CONFIG := 
    <collection xmlns="http://exist-db.org/collection-config/1.0">
        <index xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:vra="http://www.vraweb.org/vracore4.htm" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mods="http://www.loc.gov/mods/v3">
            <fulltext default="none" attributes="false"/>
            <lucene>
                <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
                
                <!--MODS-->
                <text qname="mods:title"/>
            </lucene>
            <range>
                <create qname="mods:name">
                    <field name="name-type" match="@type" type="xs:string"/>
                    <field name="name-part" match="mods:namePart" type="xs:string" case="yes"/>
                </create>
                <create qname="mods:mods">
                    <field name="mods-dateIssued" match="mods:originInfo/mods:dateIssued" type="xs:string"/>
                    <field name="mods-id" match="@ID" type="xs:string"/>
                    <field name="mods-authority" match="@authority" type="xs:string"/>
                    <field name="mods-lang" match="@lang" type="xs:string"/>
                </create>
            </range>
        </index>
    </collection>;

declare variable $rt:DATA := 
    <mods:modsCollection>
        <mods:mods ID="books/aw/Knuth86a">
            <mods:titleInfo>
                <mods:title>TeX: The Program</mods:title>
            </mods:titleInfo>
            <mods:name type="personal">
                <mods:namePart><NAME></mods:namePart>
            </mods:name>
            <mods:originInfo>
                <mods:dateIssued>1986</mods:dateIssued>
                <mods:publisher>Addison-Wesley</mods:publisher>
            </mods:originInfo>
            <mods:identifier type="isbn">0-201-13437-3</mods:identifier>
        </mods:mods>
        <mods:mods ID="books/aw/Lamport86">
            <mods:titleInfo>
                <mods:title>LaTeX: User's Guide &amp; Reference Manual</mods:title>
            </mods:titleInfo>
            <mods:name type="personal">
                <mods:namePart><NAME></mods:namePart>
            </mods:name>
            <mods:originInfo>
                <mods:dateIssued>1986</mods:dateIssued>
                <mods:publisher>Addison-Wesley</mods:publisher>
            </mods:originInfo>
            <mods:identifier type="isbn">0-201-15790-X</mods:identifier>
        </mods:mods>
    </mods:modsCollection>
;

declare
    %test:setUp
function rt:setup() {
    xmldb:create-collection("/db/system/config/db", "rangetest"),
    xmldb:store("/db/system/config/db/rangetest", "collection.xconf", $rt:COLLECTION_CONFIG),
    xmldb:create-collection("/db", "rangetest"),
    xmldb:store($rt:COLLECTION, "test.xml", $rt:DATA)
};

(:declare
    %test:tearDown
function rt:cleanup() {
    xmldb:remove($rt:COLLECTION, "test.xml"),
    xmldb:remove($rt:COLLECTION),
    xmldb:remove("/db/system/config/db/rangetest")
};:)

declare
    %test:assertEquals(1)
function rt:t00_query() {
    count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "<NAME>")])
};
<commit_msg>[ignore] New range index: tearDown commented out in tests.<commit_after>xquery version "3.0";

module namespace rt="http://exist-db.org/xquery/range/test/updates";

import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";

declare namespace mods="http://www.loc.gov/mods/v3";

declare variable $rt:COLLECTION := "/db/rangetest";

declare variable $rt:COLLECTION_CONFIG := 
    <collection xmlns="http://exist-db.org/collection-config/1.0">
        <index xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:vra="http://www.vraweb.org/vracore4.htm" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mods="http://www.loc.gov/mods/v3">
            <fulltext default="none" attributes="false"/>
            <lucene>
                <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
                
                <!--MODS-->
                <text qname="mods:title"/>
            </lucene>
            <range>
                <create qname="mods:name">
                    <field name="name-type" match="@type" type="xs:string"/>
                    <field name="name-part" match="mods:namePart" type="xs:string" case="yes"/>
                </create>
                <create qname="mods:mods">
                    <field name="mods-dateIssued" match="mods:originInfo/mods:dateIssued" type="xs:string"/>
                    <field name="mods-id" match="@ID" type="xs:string"/>
                    <field name="mods-authority" match="@authority" type="xs:string"/>
                    <field name="mods-lang" match="@lang" type="xs:string"/>
                </create>
            </range>
        </index>
    </collection>;

declare variable $rt:DATA := 
    <mods:modsCollection>
        <mods:mods ID="books/aw/Knuth86a">
            <mods:titleInfo>
                <mods:title>TeX: The Program</mods:title>
            </mods:titleInfo>
            <mods:name type="personal">
                <mods:namePart><NAME></mods:namePart>
            </mods:name>
            <mods:originInfo>
                <mods:dateIssued>1986</mods:dateIssued>
                <mods:publisher>Addison-Wesley</mods:publisher>
            </mods:originInfo>
            <mods:identifier type="isbn">0-201-13437-3</mods:identifier>
        </mods:mods>
        <mods:mods ID="books/aw/Lamport86">
            <mods:titleInfo>
                <mods:title>LaTeX: User's Guide &amp; Reference Manual</mods:title>
            </mods:titleInfo>
            <mods:name type="personal">
                <mods:namePart><NAME></mods:namePart>
            </mods:name>
            <mods:originInfo>
                <mods:dateIssued>1986</mods:dateIssued>
                <mods:publisher>Addison-Wesley</mods:publisher>
            </mods:originInfo>
            <mods:identifier type="isbn">0-201-15790-X</mods:identifier>
        </mods:mods>
    </mods:modsCollection>
;

declare
    %test:setUp
function rt:setup() {
    xmldb:create-collection("/db/system/config/db", "rangetest"),
    xmldb:store("/db/system/config/db/rangetest", "collection.xconf", $rt:COLLECTION_CONFIG),
    xmldb:create-collection("/db", "rangetest"),
    xmldb:store($rt:COLLECTION, "test.xml", $rt:DATA)
};

declare
    %test:tearDown
function rt:cleanup() {
    xmldb:remove($rt:COLLECTION, "test.xml"),
    xmldb:remove($rt:COLLECTION),
    xmldb:remove("/db/system/config/db/rangetest")
};

declare
    %test:assertEquals(1)
function rt:t00_query() {
    count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "<NAME>")])
};

{'fraction_non_alphanumeric': 0.17153034662282504, 'fraction_numerical': 0.016440608302507192, 'mean_word_length': 2.4761904761904763, 'pattern_counts': {'":': 0, '<': 129, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, 'xml': 32}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7654807', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2455, 'n_words': 304}