Toronto != toronto.  From the javadocs for StandardAnalyzer:

Filters StandardTokenizer with StandardFilter, LowerCaseFilter and StopFilter,

LowerCaseFilter does what you would expect.


--
Ian.



On Fri, Oct 3, 2014 at 3:52 AM, Xu Chu <1989ch...@gmail.com> wrote:
> Hi everyone
>
> In the following piece of code, Query test1 returns result, while Query test2 
> does not return result!! Obviously “Toronto” is appearing in the doc.
> Can any one tell me what’s wrong?
>
> Thanks
>
>
>
> private static void testRAMSpam() throws IOException
>         {
>                  RAMDirectory directory = new RAMDirectory();
>                  Analyzer analyzer = new 
> StandardAnalyzer(Version.LUCENE_4_10_0);
>              IndexWriterConfig iwc = new 
> IndexWriterConfig(Version.LUCENE_4_10_0, analyzer);
>
>                  IndexWriter writer = new IndexWriter(directory,  iwc);
>                  Document doc = new Document();
>                  doc.add(new TextField("f",
>                     "Project X took place in Waterloo. It was successful", 
> Field.Store.YES));
>                  writer.addDocument(doc);
>
>
>                   doc = new Document();
>                  doc.add(new TextField("f",
>                 "Project Y took place in Toronto. It was also good.", 
> Field.Store.YES));
>                  writer.addDocument(doc);
>                  writer.close();
>
>                  IndexReader   reader = IndexReader.open(directory);
>                  IndexSearcher   searcher = new IndexSearcher(reader);
>
>                  SpanTermQuery test1 = new SpanTermQuery(new Term("f", 
> "good"));
>                  System.out.println("test span query: " + test1.toString());
>                  TopDocs results1  = searcher.search(test1, 100);
>                  System.out.println("num result 1 : " + results1.totalHits);
>
>
>                  SpanTermQuery test2 = new SpanTermQuery(new Term("f", 
> "Toronto"));
>                  System.out.println("test span query: " + test2.toString());
>                  TopDocs results2  = searcher.search(test2, 100);
>                  System.out.println("num result 2: " + results2.totalHits);
>         }

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

Reply via email to