Results 1 to 2 of 2
  1. #1
    noorws is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Default Searching index with special chars

    Hi,

    I am indexing the data with option "Field.Index.NOT_ANALYZED" so that I can fetch it later.

    But If i search the index data with the special chars then expected result wont come up. I am escaping the search string as well :(

    -- Code Snapshot --
    Java Code:
    doc.add(new Field("id", "a+b-c", Field.Store.YES,Field.Index.NOT_ANALYZED));
    Java Code:
    searcher = new IndexSearcher(IdxPath);
    QueryParser queryParser = new QueryParser("id",
    					new StandardAnalyzer());
    String escapedString = QueryParser.escape(searchStr);
    System.out.println(escapedString);
    Query query = queryParser.parse(escapedString);
    			
    System.out.println(query.toString());
    Hits hits = searcher.search(query);
    ---
    query.toString() shows the "b c" (Without the Quotes) and this is surprising for me..

    Any help/suggestion will be appreciated.

    --
    Noor

  2. #2
    peliukasss is offline Member
    Join Date
    Feb 2010
    Posts
    21
    Rep Power
    0

    Default

    If you want to get text with quotes, first you need to give that text with quotes becouse now query parsing only text between quotes. Try this:

    doc.add(new Field("id", "\"a+b-c\"", Field.Store.YES,Field.Index.NOT_ANALYZED));

Similar Threads

  1. filter special chars
    By Strubbl in forum Lucene
    Replies: 0
    Last Post: 08-17-2009, 10:23 AM
  2. How to index the special characters in Lucene
    By talktoudaykumar in forum Lucene
    Replies: 2
    Last Post: 04-23-2009, 07:51 AM
  3. Replacing the chars within a string.
    By Mayur in forum New To Java
    Replies: 2
    Last Post: 03-27-2009, 04:00 AM
  4. Searching for Microsoft special characters
    By Tim McDaniel in forum Eclipse
    Replies: 2
    Last Post: 02-24-2009, 03:11 PM
  5. chars
    By whosadork in forum New To Java
    Replies: 6
    Last Post: 10-03-2008, 09:40 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •