lucene对文件名、文件路径进行索引,搜索的时候不能检索出来

如题,lucene对文件名、文件路径都进行了索引,因为文件名、文件路径都包含特殊字符斜杠(/)和点(.),导致搜索的时候输入文件名或者路径,都无法搜索,使用/对字符进行转义也不行,请帮忙。

部分代码如下:

protected Document getDocument(File f) throws IOException {
    Document doc = new Document();
    doc.add(new Field("contents", new FileReader(f)));

// System.out.println("=======f.getCanonicalPath()========"+f.getCanonicalPath());
// System.out.println("=======f.getName()========"+f.getName());
doc.add(new Field("fileName", f.getName(), Field.Store.YES,Field.Index.NOT_ANALYZED));
doc.add(new Field("fullpath",f.getCanonicalPath(),Field.Store.YES,Field.Index.NOT_ANALYZED));
return doc;
}

public void searchIndex(String key) throws CorruptIndexException, IOException, ParseException{
    key = "C??work?output?张三?txt";
    docDir = new File(indexDir);
    dir = FSDirectory.open(docDir);
    IndexSearcher indexSearcher = new IndexSearcher(dir);
    QueryParser parser = new QueryParser(Version.LUCENE_35, "fullpath", new StandardAnalyzer(Version.LUCENE_35));
    Query query = parser.parse(key);
    TopDocs topDocs = indexSearcher.search(query, 10);
    System.out.println("====totalHits===="+topDocs.totalHits);
    for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
        Document doc = indexSearcher.doc(scoreDoc.doc);
        System.out.println("====fullpath===="+doc.get("fullpath"));
        System.out.println("====fileName===="+doc.get("fileName"));
    }
}

请给位大神帮忙,谢谢!

转义不是反斜杠\吗,你有检查索引时和搜索时的分析器一样吗?另外,你可以用luke查看一下,你的数据到底被索引成什么。

图片说明