vendredi 8 mai 2015

Find xml files from jackrabbit with specified tag name

I'm using jackrabbit to store some xml files with the following code

public Node saveFile(Node folder, String nodeName, InputStream inputStream, String mimeType, String encoding) throws RepositoryException {
    Node fileNode = folder.addNode(nodeName, JcrConstants.NT_FILE);
    Node resourceNode = fileNode.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);

    resourceNode.setProperty(JcrConstants.JCR_MIMETYPE, mimeType);
    resourceNode.setProperty(JcrConstants.JCR_ENCODING, encoding);
    resourceNode.setProperty(JcrConstants.JCR_DATA, createBinary(folder.getSession(), inputStream));

    return fileNode;
}

private Binary createBinary(Session session, InputStream inputStream) throws RepositoryException {
        return session.getValueFactory().createBinary(new BufferedInputStream(inputStream));
    }

The mimeType is set to text/xml, I'm using the full text search function and it works fine when I try to search files by some content as keywords, but now I want to search files by xml tag name, currently it seems the tag names are not in the lucene indexes so it returns nothing, how could I make this work with jackrabbit? My SearchIndex config is as follows:

 <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
        <param name="path" value="${wsp.home}/index"/>
        <param name="useCompoundFile" value="true"/>
        <param name="minMergeDocs" value="100"/>
        <param name="volatileIdleTime" value="3"/>
        <param name="maxMergeDocs" value="100000"/>
        <param name="mergeFactor" value="10"/>
        <param name="maxFieldLength" value="10000"/>
        <param name="bufferSize" value="10"/>
        <param name="cacheSize" value="1000"/>
        <param name="forceConsistencyCheck" value="false"/>
        <param name="autoRepair" value="true"/>
        <param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
        <param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl"/>
        <param name="respectDocumentOrder" value="true"/>
        <param name="resultFetchSize" value="2147483647"/>
        <param name="extractorPoolSize" value="5"/>
        <param name="extractorTimeout" value="5000"/>
        <param name="extractorBackLogSize" value="100"/>
    </SearchIndex>

Thanks for help :-)

Aucun commentaire:

Enregistrer un commentaire