How to do Lucene search with spaceless query?

69 Views Asked by At
Document document = new Document();
document.add(new Field("ID", "100", Field.Store.YES, Field.Index.NOT_ANALYZED));
document.add(new Field("TEMPLATE_CONTENT", "dummy Just {#var#} testing a spaceless {#var#} setup dummy",
                Field.Store.YES, Field.Index.ANALYZED));
writer.addDocument(document);

am indexing dummy Just {#var#} testing a spaceless {#var#} setup dummy using lucene while am querying am using below spaceless sentance

dummyJustatestingaspacelessfreakingsetupdummy

                      or 

dummyjustatestingaspacelessfreakingsetupdummy

am not able to get a single match with above TEMPLATE_CONTENT

using the below code to serch

        query = new QueryParser(Version.LUCENE_36, "TEMPLATE_CONTENT", new StandardAnalyzer(Version.LUCENE_36))
                .parse(serchQuery);
        searcher = new IndexSearcher(index, true);
        System.out.println("......query : " + query + "\n");
        long startTime = System.currentTimeMillis();
        results = searcher.search(query, 2);
        long endTime = System.currentTimeMillis();
        System.out.println("results time taken" + (endTime - startTime) + " ms");
        for (ScoreDoc scoreDoc : results.scoreDocs) {
            System.out.println("scoreDoc : " + scoreDoc);
            Document document = searcher.doc(scoreDoc.doc);
            System.out.println("Found match: " + document.get("TEMPLATE_CONTENT") + "\n");}

Please help me to get at lease one match

0

There are 0 best solutions below