jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jyo <jenni....@gmail.com>
Subject Re: Searching problems
Date Thu, 13 May 2010 11:08:42 GMT

Hi Alex,
        I have tried to search for a word in text file from jackrabbit
repository. But my query is not returning any result. I read from the forum
that you have done successfull word search from several files like
doc,excel, pdf. Please guide me how to do the word search from the files.
Below are the code changes I have done in my application.
1) Added the Indexing-configuration.xml at the same place where
workspace.xml is there.
<?xml version="1.0"?>
<!DOCTYPE configuration SYSTEM
<configuration xmlns:jcr="http://www.jcp.org/jcr/1.0"
    <aggregate primaryType="nt:file">
2) Added the indexing-configuration.xml as a param to the SearchIndex in the
repository.xml and in workspcae.xml

3)Added the extractor clasess as parameters to the SearchIndex in
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">

4)Added the below code 
			FileInputStream file = new FileInputStream("C:\\New\\New.txt");
			Binary binary =
			Calendar cal = Calendar.getInstance(); 
			cal.set(2008, Calendar.JUNE, 10);
			//in below line getBlogEntryNode() method returns the blogEntryNode.
			Node blogEntryNode = getBlogEntryNode(blogTitle, session);
			Node newNode=blogEntryNode.addNode("newNode", "nt:folder");
			Node NewblogEntry = newNode.addNode("NewblogEntry", "nt:file");
			Node resNode = NewblogEntry.addNode("jcr:content", "nt:resource"); 
			resNode.setProperty("jcr:mimeType", "text/html");
			resNode.setProperty("jcr:data", binary);
5)New.txt file contains the text like "This is my first searching
application". Now I want to search the word "first" from my file.So my query
is like

Query query = queryManager.createQuery("//element(*,
nt:file)[jcr:contains(., 'first')]",Query.XPATH);
QueryResult queryResult = query.execute();	 
NodeIterator queryResultNodeIterator = queryResult.getNodes();
while (queryResultNodeIterator.hasNext()) {

I am not getting where I went wrong. query is not returning any result. Just
for testing I am adding only .txt file to repository and searching the text
from the file. But in my requirement I need to add any format files like
pdf,excel, word ...etc. and do the text search from those files. It is very
urgent requirement. please help me in this. If possible please give me some
sample code. Thanks in advance.


View this message in context: http://jackrabbit.510166.n4.nabble.com/Searching-problems-tp513070p2197400.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

View raw message