Java Mailing List Archive

http://www.java2.5341.com/

Home » java-user.lucene »

searching for string with a blank

David Massart

2008-09-30

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi all,
Here is a new newbee question.

I'm adding to a lucene index, documents containing a field lrt created as
follows:

doc.add( new Field( "lrt", learningResourceType

.toLowerCase(), Field.Store.NO,

Field.Index.UN_TOKENIZED ) ) ;


where possible values for learningResourceType are:


application

assessment

broadcast

case study

course

demonstration

drill and practice

educational game


In this index, searching for a string that doesn't contain a blank character
works fine


for example, lrt: application


but searching for a string with a blank does not return any results:


for example, lrt: case study doesn't work


Using lukeall, I can successfully query my index by escaping the blank with
a backslash


for example, lrt: case\ study


But it doesn't work when I try to do the same thing in Java


String query = "lrt: case\\ study"


doesn't return any result.


I've also try to QueryParser.escape( "case study") but it doesn't seem to
affect blank characters?


Thanks for your help.


David
©2008 java2.5341.com - Jax Systems, LLC, U.S.A.