Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 22125 invoked from network); 7 Feb 2010 10:59:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Feb 2010 10:59:23 -0000 Received: (qmail 40256 invoked by uid 500); 7 Feb 2010 10:59:21 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 40202 invoked by uid 500); 7 Feb 2010 10:59:21 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 40192 invoked by uid 99); 7 Feb 2010 10:59:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Feb 2010 10:59:20 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of iamrohitbanga@gmail.com designates 209.85.223.200 as permitted sender) Received: from [209.85.223.200] (HELO mail-iw0-f200.google.com) (209.85.223.200) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Feb 2010 10:59:10 +0000 Received: by iwn38 with SMTP id 38so5605204iwn.11 for ; Sun, 07 Feb 2010 02:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=UGyMw3AjGhAYFH4BTO4s8GdPt6pfuMgz898tspi/dc4=; b=YjLWOyKyYNCP8tEvwtZ+gD167RS/jTzBxkBiHOMJddWE09vNpVM8ojAmOAXFKKTyLQ IZoxu+3Zo1gnyX3i6ai1vTkK6ol4/u74y4epxfqpC9iF/tbNdSRRvLedlEgRm9n2EZOg 98n78hF1jGcwUttR+Bt138nLEP4foH/kxua0A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=mrPj2UBxlZte3RTswmraKBWLW8bTlctHfSrXJjpWsrS+l+qe9/+qszrSAXh/M82DpS aZC+b8Xi8SCgWQQFPkzmzCnqb248z/xIg+QJ19K8Pi2F2oqLvz7BsSo5+UsY1pJn9rcb Ls+s3TYT7nPEt39W3u9GIw0qmAq5BgvsoZqaY= MIME-Version: 1.0 Received: by 10.231.144.201 with SMTP id a9mr1176672ibv.69.1265540329131; Sun, 07 Feb 2010 02:58:49 -0800 (PST) In-Reply-To: References: <001601caa73a$ac403030$04c09090$@de> From: Rohit Banga Date: Sun, 7 Feb 2010 16:28:29 +0530 Message-ID: Subject: Re: hit highlighting in lucene To: java-user@lucene.apache.org, simon.willnauer@gmail.com Content-Type: multipart/alternative; boundary=001485e9a9e2c45133047f0091a2 X-Virus-Checked: Checked by ClamAV on apache.org --001485e9a9e2c45133047f0091a2 Content-Type: text/plain; charset=ISO-8859-1 // list of cities that has been indexed // each city name is a document public static final String[] names = {"New Delhi", "Bangalore", "Hyderabad", "Mumbai", "Chennai", "Kolkata", "Ahmedabad", "Kanpur", "Guwahati", "Roorkee", "Dehradun", "Lucknow", "Bhopal", "Jaipur", "Jodhpur", "Thiruvanthapuram", "Jammu", "Srinagar", "Raipur", "Pathankot", "Meerut", "Muzaffarnagar", "Agra", "Jhansi", "Gandhinagar", "Nasik", "Nagpur", "Calicut", "Trichi", "Bharatpur", "Nainital" }; // i am using the standard analyzer void highLightWords(String qStr) throws Exception { Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT); TokenStream stream = analyzer.tokenStream("name", new StringReader(qStr)); TermQuery tq = new TermQuery(new Term("name","mumbai")); QueryScorer scorer = new QueryScorer(tq); Highlighter highlighter = new Highlighter(scorer); String fragment = highlighter.getBestFragment(stream, qStr); System.out.println("\nfragment found: " + fragment); } // invoking the above function luceneTest.highLightWords("some unimportant text here Mumbai some unimportant text there~"); fragment found: some unimportant text here Mumbai some unimportant text there~ but when i change mumbai to mumbhai then while searching lucene does return hits for the correct document the fragment is not found by the above function. luceneTest.highLightWords("some unimportant text here Mumbhai some unimportant text there~"); fragment is null. On Sun, Feb 7, 2010 at 4:22 PM, Simon Willnauer < simon.willnauer@googlemail.com> wrote: > Rohit, > what kind of problems are you facing with using fuzzy query and > highlighting. > could you give us more details and maybe a small code snipped which > isolates you problem? > > simon > > On Sun, Feb 7, 2010 at 11:32 AM, Rohit Banga > wrote: > > but what about the case in which i am using fuzzy query matching. then > the > > highlighter package does not work. > > > > On Sat, Feb 6, 2010 at 8:12 PM, Uwe Schindler wrote: > > > >> There are two contrib packages for highlighting in the lucene > distribution: > >> highlighter and fast-vector-highlighter > >> > >> ----- > >> Uwe Schindler > >> H.-H.-Meier-Allee 63, D-28213 Bremen > >> http://www.thetaphi.de > >> eMail: uwe@thetaphi.de > >> > >> > >> > -----Original Message----- > >> > From: Rohit Banga [mailto:iamrohitbanga@gmail.com] > >> > Sent: Saturday, February 06, 2010 2:27 PM > >> > To: java-user@lucene.apache.org > >> > Subject: hit highlighting in lucene > >> > > >> > Hi friends > >> > > >> > I have just started using lucene and the way i want to use it is the > >> > following: > >> > > >> > i have documents consisting of names of users as one field. > >> > i have a sentence that may contain the name of some user. > >> > i perform a search for the sentence in the index using the searcher. > >> > if it contains the name of the user, then that user's document is > >> > listed on > >> > top by lucene. > >> > > >> > now i want to determine the position in the sentence where the string > >> > has > >> > been found. > >> > > >> > i am using fuzzy query matching by adding the character '~' to the > >> > sentence > >> > i am searching. > >> > so this means i cannot use the find function of the String class as is > >> > to > >> > get the position of the match. > >> > > >> > Thanks in advance > >> > > >> > -- > >> > Rohit Banga > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > >> For additional commands, e-mail: java-user-help@lucene.apache.org > >> > >> > > > > > > -- > > Rohit Banga > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > -- Rohit Banga --001485e9a9e2c45133047f0091a2--