Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 359 invoked from network); 27 Mar 2006 13:25:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Mar 2006 13:25:56 -0000 Received: (qmail 44748 invoked by uid 500); 27 Mar 2006 13:25:55 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 44569 invoked by uid 500); 27 Mar 2006 13:25:54 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 44560 invoked by uid 99); 27 Mar 2006 13:25:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Mar 2006 05:25:54 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of marcel.reutegger@gmx.net designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 27 Mar 2006 05:25:54 -0800 Received: (qmail invoked by alias); 27 Mar 2006 13:25:32 -0000 Received: from bsl-rtr.day.com (EHLO [10.0.0.68]) [212.249.34.130] by mail.gmx.net (mp039) with SMTP; 27 Mar 2006 15:25:32 +0200 X-Authenticated: #894343 Message-ID: <4427E7CB.1010208@gmx.net> Date: Mon, 27 Mar 2006 15:25:31 +0200 From: Marcel Reutegger User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: dev@jackrabbit.apache.org Subject: Re: No hits returned when searching .txt file References: <3609159.post@talk.nabble.com> In-Reply-To: <3609159.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Thomas, thomasg wrote: > Hi, any advice on this would be appreciated. I guess its an easy fix but > can't find the solution at present. Basically I have a .txt file and a .doc > file containing the same textual content. When I search for a word contained > in both files, I only get a hit from the .doc and not the .txt. This is the > relevant code: > > Node folderNode = root.addNode("foldernode", "nt:folder"); > //Now want to add this file > > File file = new > File("C:/DocumentSearchTests/testdocuments/testtextfile.txt"); > //Create an nt:file child node called "testfilenode" > Node fileNode = folderNode.addNode(file.getName(), > "nt:file"); > String mimeType = "text/plain"; > Node resourceNode = fileNode.addNode("jcr:content", > "nt:resource"); > resourceNode.setProperty("jcr:mimeType", mimeType); > //resourceNode.setProperty("jcr:encoding", ""); if jcr:encoding is missing the jcr:data stream gets read with the platform encoding. This might not be the same as your text file, e.g. if your text file uses unicode. Try the following: - set an appropriate value for jcr:encoding or - make sure that the encoding of your text file matches the jvm platform encoding. I suggest you go with the first option because it does not depend on what the default encoding of the jvm is. regards marcel > resourceNode.setProperty("jcr:data", new > FileInputStream(file)); > Calendar lastModified = Calendar.getInstance(); > lastModified.setTimeInMillis(file.lastModified()); > resourceNode.setProperty("jcr:lastModified", lastModified); > > session.save();