lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: Search By Phrase Not Working
Date Thu, 08 Oct 2009 09:26:54 GMT
Could it be as simple as the fact that "Heart of Fire" != "Rain of
Fire"?  Have you checked, with Luke for example, that the phrases
really are in the index?

Can't spot anything obviously wrong with the code.  You could cut down
your example code to a minimal self contained program that
demonstrated the problem, showing docs added and search results, and
post that here.


--
Ian.


On Thu, Oct 8, 2009 at 5:44 AM, sadronmeldir <sadronmeldir@gmail.com> wrote:
>
> Hello all,
>
> I'm having some difficult getting queries on phrases to work properly, and I
> can't figure out why. For example, a search for ("Heart of Fire") yields no
> results when it should be returning two.
>
> Below is a snippet of my code. I'm probably overlooking something trivial,
> but any help would be appreciated!
>
>
>
> ==============START CODE SNIPET==============
> String indexDir = "tmp";
> StandardAnalyzer aWrapper = new StandardAnalyzer(Version.LUCENE_CURRENT);
> IndexWriter writer = new IndexWriter(SimpleFSDirectory.open(new
> File(indexDir)), aWrapper, true, IndexWriter.MaxFieldLength.UNLIMITED);
>
> .
> .
> .
>
> Document doc = new Document();
> doc.add(new Field("year", Integer.toString(line.getYear()), Field.Store.YES,
> Field.Index.ANALYZED));
> doc.add(new Field("month", Integer.toString(line.getMonth()),
> Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("day", Integer.toString(line.getDay()), Field.Store.YES,
> Field.Index.ANALYZED));
> doc.add(new Field("hour", Integer.toString(line.getHour()), Field.Store.YES,
> Field.Index.ANALYZED));
> doc.add(new Field("minute", Integer.toString(line.getMinute()),
> Field.Store.YES, Field.Index.NOT_ANALYZED));
> doc.add(new Field("second", Integer.toString(line.getSecond()),
> Field.Store.YES, Field.Index.NOT_ANALYZED));
> doc.add(new Field("userID", line.getUserID(), Field.Store.YES,
> Field.Index.ANALYZED));
> doc.add(new Field("channelID", line.getChannelID(), Field.Store.YES,
> Field.Index.ANALYZED));
> doc.add(new Field("text", line.getText(), Field.Store.YES,
> Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
> doc.add(new Field("detail", line.getDetail(), Field.Store.YES,
> Field.Index.NOT_ANALYZED));
>
> writer.addDocument(doc);
>
> .
> .
> .
>
> writer.optimize();
> writer.close();
>
> IndexReader ir = IndexReader.open(SimpleFSDirectory.open(new
> File(indexDir)), true);
> IndexSearcher is = new IndexSearcher(ir);
> Analyzer analyzera = new StandardAnalyzer(Version.LUCENE_CURRENT);
>
> QueryParser parser = new QueryParser("text", analyzera);
> PhraseQuery query = (PhraseQuery) parser.parse("\"Rain of Fire\"");
>
> System.out.println("Query: " + query.toString());
>
> TopFieldCollector collector = TopFieldCollector.create(sort, 100000, false,
> false, false, false);
> is.search(query, collector);
> ===============END CODE SNIPET===============
> --
> View this message in context: http://www.nabble.com/Search-By-Phrase-Not-Working-tp25798292p25798292.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message